Class SimpleMessageQueue
java.lang.Object
utils.communication.communicationHandler.MessageQueue.SimpleMessageQueue
- All Implemented Interfaces:
MessageQueue
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.javatuples.Triplet<AddressInterface,
byte[], Byte> dequeue()
org.javatuples.Triplet<AddressInterface,
byte[], Byte> dequeue
(Subscription subscription) Retrieve a message from the queue.org.javatuples.Triplet<AddressInterface,
byte[], Byte> void
enqueue
(org.javatuples.Triplet<AddressInterface, byte[], Byte> packet) Add a message, separated into sender address, payload and type, as a triplet, to the queue of messages.getRegistration
(Collection<Byte> acceptableTypes, int regId) Create a new registration, demonstrating interest in incoming messages that contain one of the types provided in acceptableTypes, identified by the registration ID.getRegistration
(Collection<Byte> acceptableTypes, InstanceID instanceID, int regId) Create a new registration, demonstrating interest in incoming messages that contain one of the types provided in acceptableTypes, identified by the registration ID, for a specific instance ID.int
size()
-
Constructor Details
-
SimpleMessageQueue
public SimpleMessageQueue()
-
-
Method Details
-
getRegistration
Description copied from interface:MessageQueue
Create a new registration, demonstrating interest in incoming messages that contain one of the types provided in acceptableTypes, identified by the registration ID. If any one of the types present in accpetableTypes has been registered before, then no new subscription is created.- Specified by:
getRegistration
in interfaceMessageQueue
- Parameters:
acceptableTypes
- Set containing the message types the new subsciption should be keeping track.regId
- Integer defining a unique key for the new subscription.- Returns:
- New subscription, provided no repeated message types are present. If they are, then NULL is returned.
-
getRegistration
public Subscription getRegistration(Collection<Byte> acceptableTypes, InstanceID instanceID, int regId) Description copied from interface:MessageQueue
Create a new registration, demonstrating interest in incoming messages that contain one of the types provided in acceptableTypes, identified by the registration ID, for a specific instance ID. If a previous subscription as been created for the same instance ID, then no new subscription is created.- Specified by:
getRegistration
in interfaceMessageQueue
- Parameters:
acceptableTypes
- Set containing the message types the new subsciption should be keeping track.instanceID
- Object defining the unique identifier of the consumer (subscriber). Only messages tagged with this instance ID will be delivered to this consumer.regId
- Integer defining a unique key for the new subscription.- Returns:
- New subscription, provided this consumer hasn't made a subscription before. If they have, then NULL is returned.
-
enqueue
Description copied from interface:MessageQueue
Add a message, separated into sender address, payload and type, as a triplet, to the queue of messages.- Specified by:
enqueue
in interfaceMessageQueue
- Parameters:
packet
- Triplet containing the sender address, payload and message type.
-
dequeue
-
dequeue
Description copied from interface:MessageQueue
Retrieve a message from the queue. Should retrieve the oldest message that fits into the needs of a given subscription. If no message is available in the queue that satisfies the subscription, then the method blocks until such a message is available to dequeue.- Specified by:
dequeue
in interfaceMessageQueue
- Parameters:
subscription
- Object that describes the type of message wanted, as well as the consumer.- Returns:
- A message packet, containing the sender address, payload and message type, that fits the subscription's requirements.
-
dequeue
-
generateNewWatcher
-
size
public int size()
-