MaDKit forum

Welcome All !
Please, use explicit topic names when creating new threads. Thanks.

You are not logged in.

#1 2017-02-05 13:04:36

houda92
Member
From: Algérie
Registered: 2015-11-25
Posts: 2

Send messages

hello dears
is there a trick or a function that test if the message was sent or not
Nb: i use MaDKit 5.0.0.10

Offline

#2 2017-02-05 18:36:30

fmichel
Administrator
From: Montpellier
Registered: 2009-03-24
Posts: 172
Website

Re: Send messages

Hello,

First, I advice you to check the last version; 5.0.0.10 is quite old now.

sendMessage methods return a ReturnCode that gives this kind of information (cf. the madkit.kernel.AbstractAgent.ReturnCode javadoc)

So, for instance:
ReturnCode r = sendMessage(m,target);
if(r != ReturnCode.SUCCESS){
  getLogger().info("there was a problem "+r);
}

But more simply, sendMessage methods are automatically  logged.
So, for debugging purposes :
setLogLevel(Level.FINEST);//somewhere before
sendMessage(m,target);

will print out what the result is

Even more simply, if you are just interested in printing the ReturnCode only if there was a problem, use

getLogger().setWarningLogLevel(Level.FINE);//which is equal to the default log level of agents, so that warnings will be displayed when methods do not return SUCCESS
sendMessage(m,target);

Moreover, if the target is running on the same kernel, a SUCCESS also means that the message was safely delivered in the target's mailbox.

Offline

#3 2017-03-28 16:50:32

houda92
Member
From: Algérie
Registered: 2015-11-25
Posts: 2

Re: Send messages

Thanks for your answer it woks very well

Offline

Board footer