public class MemoryMessageQueue extends MessageQueue
This queue is typically used for testing to mock real queues.
### Configuration parameters ###
### References ###
### Example ###
MessageQueue queue = new MessageQueue("myqueue");
queue.send("123", new MessageEnvelop(null, "mymessage", "ABC"));
queue.receive("123", 0);
MessageQueue,
MessagingCapabilities_capabilities, _connectionResolver, _counters, _credentialResolver, _kind, _lock, _logger, _name| Constructor and Description |
|---|
MemoryMessageQueue()
Creates a new instance of the message queue.
|
MemoryMessageQueue(String name)
Creates a new instance of the message queue.
|
| Modifier and Type | Method and Description |
|---|---|
void |
abandon(MessageEnvelop message)
Returnes message into the queue and makes it available for all subscribers to
receive it again.
|
void |
clear(String correlationId)
Clears component state.
|
void |
close(String correlationId)
Closes component and frees used resources.
|
void |
complete(MessageEnvelop message)
Permanently removes a message from the queue.
|
void |
endListen(String correlationId)
Ends listening for incoming messages.
|
Long |
getMessageCount()
Gets the current number of messages in the queue to be delivered.
|
boolean |
isOpen()
Checks if the component is opened.
|
void |
listen(String correlationId,
IMessageReceiver receiver)
Listens for incoming messages and blocks the current thread until queue is
closed.
|
void |
moveToDeadLetter(MessageEnvelop message)
Permanently removes a message from the queue and sends it to dead letter
queue.
|
void |
open(String correlationId,
org.pipservices.components.connect.ConnectionParams connection,
org.pipservices.components.auth.CredentialParams credential)
Opens the component with given connection and credential parameters.
|
MessageEnvelop |
peek(String correlationId)
Peeks a single incoming message from the queue without removing it.
|
List<MessageEnvelop> |
peekBatch(String correlationId,
int messageCount)
Peeks multiple incoming messages from the queue without removing them.
|
MessageEnvelop |
receive(String correlationId,
long waitTimeout)
Receives an incoming message and removes it from the queue.
|
void |
renewLock(MessageEnvelop message,
long lockTimeout)
Renews a lock on a message that makes it invisible from other receivers in
the queue.
|
void |
send(String correlationId,
MessageEnvelop message)
Sends a message into the queue.
|
String |
toString()
Override toString() method, string representation of queue.
|
beginListen, configure, getCapabilities, getName, open, sendAsObject, setReferencespublic MemoryMessageQueue()
public MemoryMessageQueue(String name)
name - (optional) a queue name.MessagingCapabilitiespublic boolean isOpen()
isOpen in interface org.pipservices.commons.run.IOpenableisOpen in class MessageQueuepublic void open(String correlationId, org.pipservices.components.connect.ConnectionParams connection, org.pipservices.components.auth.CredentialParams credential)
open in class MessageQueuecorrelationId - (optional) transaction id to trace execution through
call chain.connection - connection parameterscredential - credential parameterspublic void close(String correlationId)
close in interface org.pipservices.commons.run.IClosableclose in class MessageQueuecorrelationId - (optional) transaction id to trace execution through
call chain.public void clear(String correlationId)
clear in class MessageQueuecorrelationId - (optional) transaction id to trace execution through
call chain.public Long getMessageCount()
getMessageCount in interface IMessageQueuegetMessageCount in class MessageQueuepublic void send(String correlationId, MessageEnvelop message)
send in interface IMessageQueuesend in class MessageQueuecorrelationId - (optional) transaction id to trace execution through
call chain.message - a message envelop to be sent.public MessageEnvelop peek(String correlationId)
peek in interface IMessageQueuepeek in class MessageQueuecorrelationId - (optional) transaction id to trace execution through
call chain.public List<MessageEnvelop> peekBatch(String correlationId, int messageCount)
peekBatch in interface IMessageQueuepeekBatch in class MessageQueuecorrelationId - (optional) transaction id to trace execution through
call chain.messageCount - a maximum number of messages to peek.public MessageEnvelop receive(String correlationId, long waitTimeout)
receive in interface IMessageQueuereceive in class MessageQueuecorrelationId - (optional) transaction id to trace execution through
call chain.waitTimeout - a timeout in milliseconds to wait for a message to come.public void renewLock(MessageEnvelop message, long lockTimeout)
renewLock in interface IMessageQueuerenewLock in class MessageQueuemessage - a message to extend its lock.lockTimeout - a locking timeout in milliseconds.public void abandon(MessageEnvelop message)
abandon in interface IMessageQueueabandon in class MessageQueuemessage - a message to return.public void complete(MessageEnvelop message)
complete in interface IMessageQueuecomplete in class MessageQueuemessage - a message to remove.public void moveToDeadLetter(MessageEnvelop message)
moveToDeadLetter in interface IMessageQueuemoveToDeadLetter in class MessageQueuemessage - a message to be removed.public void listen(String correlationId, IMessageReceiver receiver)
listen in interface IMessageQueuelisten in class MessageQueuecorrelationId - (optional) transaction id to trace execution through
call chain.receiver - a receiver to receive incoming messages.IMessageReceiver,
receive(String, long)public void endListen(String correlationId)
endListen in interface IMessageQueueendListen in class MessageQueuecorrelationId - (optional) transaction id to trace execution through
call chain.public String toString()
toString in class MessageQueueCopyright © 2018. All rights reserved.