Class InMemoryQueue

java.lang.Object
com.epam.fixengine.jms.storage.queue.InMemoryQueue
All Implemented Interfaces:
IQueue
Direct Known Subclasses:
PersistentInMemoryQueue

public class InMemoryQueue extends Object implements IQueue
  • Constructor Summary

    Constructors
    Constructor
    Description
    InMemoryQueue(int capacity, long publishTimeout)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(byte[] itemBody)
    Inserts the specified element at the tail of this queue, waiting for space to become available if the queue is full.
    void
    add(byte[] itemBody, String jmsMessageParams)
    Inserts the specified element at the tail of this queue, waiting for space to become available if the queue is full.
    protected void
    addRestored(int seqNum, byte[] data, String jmsMessageParam)
     
    void
    Atomically removes all of the elements from this queue.
    void
    Removes polled object from the queue.
    void
    commit(IQueueable[] batchItems, int size)
    Removes polled objects from the queue.
    void
    Return element to queue.
    void
    failedProcessing(IQueueable[] batchItems, int size)
    Return element to queue.
    void
    Initializes queue.
    boolean
    Checks if queue is currently empty.
    protected boolean
    Check is empty without lock
    protected void
     
    protected void
     
    Poll object from the queue (doesn't remove it from queue yet!).
    protected void
     
    protected void
    setSeqNum(int seqNum)
     
    void
    Gracefully shutdowns queue.
    int
    Returns the number of elements in this queue.
    Retrieves and mark as processing the head of this queue, waiting if necessary until an element becomes available.
    int
    take(IQueueable[] batch)
    Retrieves and mark as processing the batch elements from head of this queue, waiting if necessary until at least one element becomes available.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • InMemoryQueue

      public InMemoryQueue(int capacity, long publishTimeout)
  • Method Details

    • initialize

      public void initialize() throws IOException
      Description copied from interface: IQueue
      Initializes queue. That includes restore of previously saved queue content for persistent queues.
      Specified by:
      initialize in interface IQueue
      Throws:
      IOException
      See Also:
    • size

      public int size()
      Returns the number of elements in this queue.
      Specified by:
      size in interface IQueue
      Returns:
      the number of elements in this queue
    • isEmpty

      public boolean isEmpty()
      Description copied from interface: IQueue
      Checks if queue is currently empty.
      Specified by:
      isEmpty in interface IQueue
      Returns:
      true if empty
      See Also:
    • isEmptyInner

      protected boolean isEmptyInner()
      Check is empty without lock
      Returns:
    • add

      public void add(byte[] itemBody) throws InterruptedException, IOException
      Inserts the specified element at the tail of this queue, waiting for space to become available if the queue is full.
      Specified by:
      add in interface IQueue
      Throws:
      IllegalStateException
      NullPointerException
      InterruptedException
      IOException
    • add

      public void add(byte[] itemBody, String jmsMessageParams) throws InterruptedException, IOException
      Inserts the specified element at the tail of this queue, waiting for space to become available if the queue is full.
      Specified by:
      add in interface IQueue
      Throws:
      IllegalStateException
      NullPointerException
      InterruptedException
      IOException
    • poll

      public IQueueable poll()
      Description copied from interface: IQueue
      Poll object from the queue (doesn't remove it from queue yet!). Change tem state to processing.
      Specified by:
      poll in interface IQueue
      Returns:
      the head of this queue, or null if this queue is empty
      See Also:
    • take

      public IQueueable take()
      Retrieves and mark as processing the head of this queue, waiting if necessary until an element becomes available.
      Specified by:
      take in interface IQueue
      Returns:
      the head of this queue
      Throws:
      IllegalStateException - if interrupted while waiting
    • take

      public int take(IQueueable[] batch)
      Description copied from interface: IQueue
      Retrieves and mark as processing the batch elements from head of this queue, waiting if necessary until at least one element becomes available.
      Specified by:
      take in interface IQueue
      Returns:
      the number of read elements
    • failedProcessing

      public void failedProcessing(IQueueable object)
      Description copied from interface: IQueue
      Return element to queue. Item will be available again for handing.
      Specified by:
      failedProcessing in interface IQueue
    • failedProcessing

      public void failedProcessing(IQueueable[] batchItems, int size)
      Description copied from interface: IQueue
      Return element to queue. Items will be available again for handing.
      Specified by:
      failedProcessing in interface IQueue
      size - the number of items in batch
    • commit

      public void commit(IQueueable object) throws IOException
      Description copied from interface: IQueue
      Removes polled object from the queue.
      Specified by:
      commit in interface IQueue
      Throws:
      IOException
      See Also:
    • commit

      public void commit(IQueueable[] batchItems, int size) throws IOException
      Description copied from interface: IQueue
      Removes polled objects from the queue.
      Specified by:
      commit in interface IQueue
      size - the number of items in batch
      Throws:
      IOException
    • clear

      public void clear() throws IOException
      Atomically removes all of the elements from this queue. The queue will be empty after this call returns.
      Specified by:
      clear in interface IQueue
      Throws:
      IOException
    • shutdown

      public void shutdown()
      Description copied from interface: IQueue
      Gracefully shutdowns queue.
      Specified by:
      shutdown in interface IQueue
      See Also:
    • resetSeqNum

      protected void resetSeqNum()
    • setSeqNum

      protected void setSeqNum(int seqNum)
    • addRestored

      protected void addRestored(int seqNum, byte[] data, String jmsMessageParam)
    • onInsert

      protected void onInsert(IQueueable x) throws IOException
      Throws:
      IOException
    • onCommit

      protected void onCommit(IQueueable x) throws IOException
      Throws:
      IOException