title: Exchange messages on JADEX 2.4
body: <p>I have to make a work with BDI Agents and for that i will use JADEX 2.4 but i have a big problem. The documentation is a bit poor and i can't exchange messages between agents. </p>
  
  <p>I have read this article <a href="http://www.activecomponents.org/bin/view/AC+Tutorial/05+Provided+Services" rel="nofollow">http://www.activecomponents.org/bin/view/AC+Tutorial/05+Provided+Services</a></p>
  
  <p>And i'm trying make the same thing on my code but no success. I need to know how to do 2 things for make my work: send a message from one agent to other, and send a message from one agent to all agents. Anyone knows how to do that?</p>
  
  <p>The code that i have is the following:</p>
  
  <p><strong>ChatSystem.java</strong></p>
  
  <pre><code>package agents;
  
  import java.text.DateFormat;
  import java.text.SimpleDateFormat;
  import ....
  
  @Service
  public class ChatSystem implements IChatService{
  
      @ServiceComponent
      protected IInternalAccess agent;
      protected IClockService clock;
      protected DateFormat format;
  
      @ServiceStart
      public IFuture&lt;IClockService&gt; startService(){
  
          format = new SimpleDateFormat("hh:mm:ss");
          final Future&lt;IClockService&gt; ret = new Future&lt;IClockService&gt;();
          IFuture&lt;IClockService&gt; fut = agent.getServiceContainer().getRequiredService("clockservice");
          fut.addResultListener(new DelegationResultListener&lt;IClockService&gt;(ret)
          {
            public void customResultAvailable(IClockService result)
            {
              clock = result;
              super.customResultAvailable(null);
            }
          });
          return ret;
      }
  
      @Override
      public IFuture&lt;Void&gt; message(String nick, String text,
              boolean privatemessage) {
          // TODO Auto-generated method stub
          //System.out.println(" received at" + text);
          System.out.println(agent.getComponentIdentifier().getLocalName()+" received at "
                  +" from: "+nick+" message: "+text);
          return null;
      }
  }
  </code></pre>
  
  <p><strong>HelperAgent.java</strong></p>
  
  <pre><code>package agents;
  import java.util.Collection;
  import java.util.Date;
  import java.util.Iterator;
  import .....
  
  @Agent
  @Service
  @RequiredServices({@RequiredService(name="clockservice", type=IClockService.class,binding=@Binding(scope=RequiredServiceInfo.SCOPE_PLATFORM)),@RequiredService(name="chatservices", type=IClockService.class,binding=@Binding(scope=RequiredServiceInfo.SCOPE_PLATFORM,dynamic=true),multiple=true)})
  @ProvidedServices(@ProvidedService(type=IChatService.class, implementation=@Implementation(ChatSystem.class)))
  
  public class HelperAgent {
  
      @Agent
      protected MicroAgent agent;
      @AgentBody
      public void AgentBody()
      {
  
          IFuture&lt;IClockService&gt; fut = agent.getServiceContainer().getRequiredService("clockservice");
          fut.addResultListener(new DefaultResultListener&lt;IClockService&gt;()
          {
            public void resultAvailable(IClockService cs)
            {
              System.out.println("Time for a chat, buddy: "+new Date(cs.getTime()));
            }
          });
  
          IFuture&lt;Collection&lt;IChatService&gt;&gt; chatservices = agent.getServiceContainer().getRequiredServices("chatservices");
          chatservices.addResultListener(new DefaultResultListener&lt;Collection&lt;IChatService&gt;&gt;()
          {
            public void resultAvailable(Collection&lt;IChatService&gt; result)
            {
              for(Iterator&lt;IChatService&gt; it=result.iterator(); it.hasNext(); )
              {
                IChatService cs = it.next();
                cs.message(agent.getComponentIdentifier().getName(), "test",false);
              }
            }
          });
  
      }
  }
  </code></pre>
  
  <p>Anyone can help me?</p>
  
  <p>Regards </p>