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 TypeMethodDescriptionvoid
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
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
clear()
Atomically removes all of the elements from this queue.void
commit
(IQueueable object) Removes polled object from the queue.void
commit
(IQueueable[] batchItems, int size) Removes polled objects from the queue.void
failedProcessing
(IQueueable object) Return element to queue.void
failedProcessing
(IQueueable[] batchItems, int size) Return element to queue.void
Initializes queue.boolean
isEmpty()
Checks if queue is currently empty.protected boolean
Check is empty without lockprotected void
protected void
poll()
Poll object from the queue (doesn't remove it from queue yet!).protected void
protected void
setSeqNum
(int seqNum) void
shutdown()
Gracefully shutdowns queue.int
size()
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.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.
-
Constructor Details
-
InMemoryQueue
public InMemoryQueue(int capacity, long publishTimeout)
-
-
Method Details
-
initialize
Description copied from interface:IQueue
Initializes queue. That includes restore of previously saved queue content for persistent queues.- Specified by:
initialize
in 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:IQueue
Checks 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:
add
in interfaceIQueue
- Throws:
IllegalStateException
NullPointerException
InterruptedException
IOException
-
add
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 interfaceIQueue
- Throws:
IllegalStateException
NullPointerException
InterruptedException
IOException
-
poll
Description copied from interface:IQueue
Poll 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:
take
in interfaceIQueue
- Returns:
- the head of this queue
- Throws:
IllegalStateException
- if interrupted while waiting
-
take
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. -
failedProcessing
Description copied from interface:IQueue
Return element to queue. Item will be available again for handing.- Specified by:
failedProcessing
in interfaceIQueue
-
failedProcessing
Description copied from interface:IQueue
Return element to queue. Items will be available again for handing.- Specified by:
failedProcessing
in interfaceIQueue
size
- the number of items in batch
-
commit
Description copied from interface:IQueue
Removes polled object from the queue.- Specified by:
commit
in interfaceIQueue
- Throws:
IOException
- See Also:
-
commit
Description copied from interface:IQueue
Removes polled objects from the queue.- Specified by:
commit
in interfaceIQueue
size
- 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:
clear
in interfaceIQueue
- Throws:
IOException
-
shutdown
public void shutdown()Description copied from interface:IQueue
Gracefully shutdowns queue. -
resetSeqNum
protected void resetSeqNum() -
setSeqNum
protected void setSeqNum(int seqNum) -
addRestored
-
onInsert
- Throws:
IOException
-
onCommit
- Throws:
IOException
-