Class ReplicatedMessageQueueAgent
- java.lang.Object
-
- jadex.micro.examples.messagequeue.replicated.ReplicatedMessageQueueAgent
-
- All Implemented Interfaces:
IMessageQueueService
,IMessageQueueReplicableService
,IMessageQueueReplicationService
public class ReplicatedMessageQueueAgent extends java.lang.Object implements IMessageQueueReplicableService, IMessageQueueReplicationService
This agent represents a part of a distributed, replicable message queue. It offers a message queue service that is used by the local clients. Also it offers and uses a remote message queue service where other remote services can subscribe to receive and distribute messages from local clients.
-
-
Field Summary
Fields Modifier and Type Field Description protected IInternalAccess
agent
The agent.protected java.lang.String
id
The service idprotected java.util.Map<java.lang.String,java.util.List<SubscriptionIntermediateFuture<Event>>>
localsubscribers
The map of local subscribers.protected java.util.Map<java.lang.String,java.util.List<SubscriptionIntermediateFuture<Event>>>
repsubscribers
The map of the replication subscribers.protected java.util.Map<java.lang.String,java.util.List<ReplicationSubscription>>
repsubscriptions
The map ofReplicationSubscription
sprotected java.lang.Integer
searchinterval
The search interval argument.
-
Constructor Summary
Constructors Constructor Description ReplicatedMessageQueueAgent()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
agentBody()
void
agentCreated()
Called on agent creation.java.lang.String
getIdString()
Returns the services unique Id.IFuture<java.lang.Void>
publish(java.lang.String topic, Event event)
Publish a new event to the queue.IFuture<java.lang.Void>
publish(java.lang.String topic, Event event, java.lang.Boolean replicate)
Publish a new event to the queue.ISubscriptionIntermediateFuture<Event>
subscribe(java.lang.String topic)
Subscribe to a specific topic.ISubscriptionIntermediateFuture<Event>
subscribeForReplication(java.lang.String topic)
Subscribe to a specific topic.
-
-
-
Field Detail
-
agent
protected IInternalAccess agent
The agent.
-
localsubscribers
protected java.util.Map<java.lang.String,java.util.List<SubscriptionIntermediateFuture<Event>>> localsubscribers
The map of local subscribers.
-
repsubscribers
protected java.util.Map<java.lang.String,java.util.List<SubscriptionIntermediateFuture<Event>>> repsubscribers
The map of the replication subscribers.
-
repsubscriptions
protected java.util.Map<java.lang.String,java.util.List<ReplicationSubscription>> repsubscriptions
The map ofReplicationSubscription
s
-
id
protected java.lang.String id
The service id
-
searchinterval
protected java.lang.Integer searchinterval
The search interval argument.
-
-
Method Detail
-
agentCreated
public void agentCreated()
Called on agent creation.
-
agentBody
public void agentBody()
-
subscribeForReplication
public ISubscriptionIntermediateFuture<Event> subscribeForReplication(java.lang.String topic)
Subscribe to a specific topic. New events that fit to the topic are forwarded to all replication subscribers as intermediate results. A subscribe can unsubscribe by terminating the future.- Specified by:
subscribeForReplication
in interfaceIMessageQueueReplicationService
- Parameters:
topic
- The topic.- Returns:
- The events.
-
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. Every time when someone subscribe for local messages the server also subscribe for the given topic by all the other remote services.- 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, java.lang.Boolean replicate)
Publish a new event to the queue.- Specified by:
publish
in interfaceIMessageQueueReplicableService
- Parameters:
topic
- The topic.event
- The event to publish.replicate
- Should the event be replicated among all message queues?
-
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.
-
getIdString
public java.lang.String getIdString()
Returns the services unique Id.- Specified by:
getIdString
in interfaceIMessageQueueReplicationService
- Returns:
- the service Id.
-
-