Class InMemoryQueue
java.lang.Object
com.epam.fixengine.jms.storage.queue.InMemoryQueue
- All Implemented Interfaces:
IQueue
- Direct Known Subclasses:
PersistentInMemoryQueue
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(byte[] itemBody) Inserts the specified element at the tail of this queue, waiting for space to become available if the queue is full.voidInserts the specified element at the tail of this queue, waiting for space to become available if the queue is full.protected voidaddRestored(int seqNum, byte[] data, String jmsMessageParam) voidclear()Atomically removes all of the elements from this queue.voidcommit(IQueueable object) Removes polled object from the queue.voidcommit(IQueueable[] batchItems, int size) Removes polled objects from the queue.voidfailedProcessing(IQueueable object) Return element to queue.voidfailedProcessing(IQueueable[] batchItems, int size) Return element to queue.voidInitializes queue.booleanisEmpty()Checks if queue is currently empty.protected booleanCheck is empty without lockprotected voidprotected voidpoll()Poll object from the queue (doesn't remove it from queue yet!).protected voidprotected voidsetSeqNum(int seqNum) voidshutdown()Gracefully shutdowns queue.intsize()Returns the number of elements in this queue.take()Retrieves and mark as processing the head of this queue, waiting if necessary until an element becomes available.inttake(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.
-
Constructor Details
-
InMemoryQueue
public InMemoryQueue(int capacity, long publishTimeout)
-
-
Method Details
-
initialize
Description copied from interface:IQueueInitializes queue. That includes restore of previously saved queue content for persistent queues.- Specified by:
initializein interfaceIQueue- Throws:
IOException- See Also:
-
size
public int size()Returns the number of elements in this queue. -
isEmpty
public boolean isEmpty()Description copied from interface:IQueueChecks if queue is currently empty. -
isEmptyInner
protected boolean isEmptyInner()Check is empty without lock- Returns:
-
add
Inserts the specified element at the tail of this queue, waiting for space to become available if the queue is full.- Specified by:
addin interfaceIQueue- Throws:
IllegalStateExceptionNullPointerExceptionInterruptedExceptionIOException
-
add
Inserts the specified element at the tail of this queue, waiting for space to become available if the queue is full.- Specified by:
addin interfaceIQueue- Throws:
IllegalStateExceptionNullPointerExceptionInterruptedExceptionIOException
-
poll
Description copied from interface:IQueuePoll object from the queue (doesn't remove it from queue yet!). Change tem state to processing. -
take
Retrieves and mark as processing the head of this queue, waiting if necessary until an element becomes available.- Specified by:
takein interfaceIQueue- Returns:
- the head of this queue
- Throws:
IllegalStateException- if interrupted while waiting
-
take
Description copied from interface:IQueueRetrieves and mark as processing the batch elements from head of this queue, waiting if necessary until at least one element becomes available. -
failedProcessing
Description copied from interface:IQueueReturn element to queue. Item will be available again for handing.- Specified by:
failedProcessingin interfaceIQueue
-
failedProcessing
Description copied from interface:IQueueReturn element to queue. Items will be available again for handing.- Specified by:
failedProcessingin interfaceIQueuesize- the number of items in batch
-
commit
Description copied from interface:IQueueRemoves polled object from the queue.- Specified by:
commitin interfaceIQueue- Throws:
IOException- See Also:
-
commit
Description copied from interface:IQueueRemoves polled objects from the queue.- Specified by:
commitin interfaceIQueuesize- the number of items in batch- Throws:
IOException
-
clear
Atomically removes all of the elements from this queue. The queue will be empty after this call returns.- Specified by:
clearin interfaceIQueue- Throws:
IOException
-
shutdown
public void shutdown()Description copied from interface:IQueueGracefully shutdowns queue. -
resetSeqNum
protected void resetSeqNum() -
setSeqNum
protected void setSeqNum(int seqNum) -
addRestored
-
onInsert
- Throws:
IOException
-
onCommit
- Throws:
IOException
-