Package jade.core
Class TemplateBasedMessageQueue
- java.lang.Object
-
- jade.core.ExtendedMessageQueue
-
- jade.core.TemplateBasedMessageQueue
-
- All Implemented Interfaces:
MessageQueue
public class TemplateBasedMessageQueue extends ExtendedMessageQueue
Enhanced version of the agent MessageQueue that supports creating dedicated queues of messages to explicitly registered MessageTemplates.- Author:
- Caire
- See Also:
registerTemplate(),Agent.createMessageQueue()
-
-
Field Summary
-
Fields inherited from class jade.core.ExtendedMessageQueue
list, maxSize, myAgent, myLogger, warningDiscardTemplate, warningLimit
-
-
Constructor Summary
Constructors Constructor Description TemplateBasedMessageQueue()TemplateBasedMessageQueue(int maxSize, int warningLimit, MessageTemplate warningDiscardTemplate, Agent a)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcopyTo(List messages)Copy all messages to a given list.Stringdump(int limit)ACLMessagereceive(MessageTemplate pattern)Return and remove the first message that matches the specified message template.List<ACLMessage>receive(MessageTemplate pattern, int max)Return and remove the first n messages that match the specified message template.voidregisterTemplate(MessageTemplate tpl)Register a specific MessageTemplate to this MessageQueue.-
Methods inherited from class jade.core.ExtendedMessageQueue
addFirst, addLast, getMaxSize, handleDiscarded, isEmpty, setMaxSize, size
-
-
-
-
Constructor Detail
-
TemplateBasedMessageQueue
public TemplateBasedMessageQueue(int maxSize, int warningLimit, MessageTemplate warningDiscardTemplate, Agent a)
-
TemplateBasedMessageQueue
public TemplateBasedMessageQueue()
-
-
Method Detail
-
registerTemplate
public void registerTemplate(MessageTemplate tpl)
Register a specific MessageTemplate to this MessageQueue. All incoming messages matching this template will be inserted into a dedicated queue and calls to receive() with the registered template as parameter will extract messages from the dedicated queue only. In situations with heavy load of messages (several messages in the agent queue), this can speed-up performances of the receive() method a lot. If an incoming message matches more than one registered template it is inserted in the queue associated to the first matching template.- Parameters:
tpl- The MessageTemplate to be registered
-
receive
public ACLMessage receive(MessageTemplate pattern)
Description copied from interface:MessageQueueReturn and remove the first message that matches the specified message template.- Specified by:
receivein interfaceMessageQueue- Overrides:
receivein classExtendedMessageQueue
-
receive
public List<ACLMessage> receive(MessageTemplate pattern, int max)
Description copied from interface:MessageQueueReturn and remove the first n messages that match the specified message template.- Specified by:
receivein interfaceMessageQueue- Overrides:
receivein classExtendedMessageQueue
-
copyTo
public void copyTo(List messages)
Description copied from interface:MessageQueueCopy all messages to a given list.- Specified by:
copyToin interfaceMessageQueue- Overrides:
copyToin classExtendedMessageQueue
-
dump
public String dump(int limit)
- Overrides:
dumpin classExtendedMessageQueue
-
-