Class MessageQueueAgent
- java.lang.Object
-
- jadex.micro.examples.messagequeue.MessageQueueAgent
-
- All Implemented Interfaces:
IMessageQueueService
public class MessageQueueAgent extends java.lang.Object implements IMessageQueueService
This agent represents the central message queue. It offers a message queue service that is used by the clients.
-
-
Field Summary
Fields Modifier and Type Field Description protected IInternalAccess
agent
The agent.protected java.util.Map<java.lang.String,java.util.List<SubscriptionIntermediateFuture<Event>>>
subscribers
The map of subscribers.
-
Constructor Summary
Constructors Constructor Description MessageQueueAgent()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
agentCreated()
Called on agent creation.IFuture<java.lang.Void>
publish(java.lang.String topic, Event event)
Publish a new event to the queue.ISubscriptionIntermediateFuture<Event>
subscribe(java.lang.String topic)
Subscribe to a specific topic.
-
-
-
Field Detail
-
agent
protected IInternalAccess agent
The agent.
-
subscribers
protected java.util.Map<java.lang.String,java.util.List<SubscriptionIntermediateFuture<Event>>> subscribers
The map of subscribers.
-
-
Method Detail
-
agentCreated
public void agentCreated()
Called on agent creation.
-
subscribe
public ISubscriptionIntermediateFuture<Event> subscribe(java.lang.String topic)
Subscribe to a specific topic. New events that fit to the topic are forwarded to all subscribers as intermediate results. A subscribe can unsubscribe by terminating the future.- Specified by:
subscribe
in interfaceIMessageQueueService
- Parameters:
topic
- The topic.- Returns:
- The events.
-
publish
public IFuture<java.lang.Void> publish(java.lang.String topic, Event event)
Publish a new event to the queue.- Specified by:
publish
in interfaceIMessageQueueService
- Parameters:
topic
- The topic.event
- The event to publish.
-
-