Class SimpleMessageQueue

java.lang.Object
utils.communication.communicationHandler.MessageQueue.SimpleMessageQueue
All Implemented Interfaces:
MessageQueue

public class SimpleMessageQueue extends Object implements MessageQueue
  • Constructor Details

    • SimpleMessageQueue

      public SimpleMessageQueue()
  • Method Details

    • getRegistration

      public Subscription getRegistration(Collection<Byte> acceptableTypes, 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. If any one of the types present in accpetableTypes has been registered before, then no new subscription is created.
      Specified by:
      getRegistration in interface MessageQueue
      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 interface MessageQueue
      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

      public void enqueue(org.javatuples.Triplet<AddressInterface,byte[],Byte> packet)
      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 interface MessageQueue
      Parameters:
      packet - Triplet containing the sender address, payload and message type.
    • dequeue

      public org.javatuples.Triplet<AddressInterface,byte[],Byte> dequeue()
    • dequeue

      public org.javatuples.Triplet<AddressInterface,byte[],Byte> dequeue(Subscription subscription)
      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 interface MessageQueue
      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

      public org.javatuples.Triplet<AddressInterface,byte[],Byte> dequeue(Byte acceptableType)
    • generateNewWatcher

      public Condition generateNewWatcher()
    • size

      public int size()