public abstract class MessageQueue extends Object implements IMessageQueue, org.pipservices.commons.refer.IReferenceable, org.pipservices.commons.config.IConfigurable, org.pipservices.commons.run.IOpenable, org.pipservices.commons.run.IClosable
### Configuration parameters ###
### References ###
| Modifier and Type | Field and Description |
|---|---|
protected MessagingCapabilities |
_capabilities |
protected org.pipservices.components.connect.ConnectionResolver |
_connectionResolver |
protected org.pipservices.components.count.CompositeCounters |
_counters |
protected org.pipservices.components.auth.CredentialResolver |
_credentialResolver |
protected String |
_kind |
protected Object |
_lock |
protected org.pipservices.components.log.CompositeLogger |
_logger |
protected String |
_name |
| Constructor and Description |
|---|
MessageQueue()
Creates a new instance of the message queue.
|
MessageQueue(String name)
Creates a new instance of the message queue.
|
MessageQueue(String name,
org.pipservices.commons.config.ConfigParams config)
Creates a new instance of the message queue.
|
| Modifier and Type | Method and Description |
|---|---|
abstract void |
abandon(MessageEnvelop message)
Returnes message into the queue and makes it available for all subscribers to
receive it again.
|
void |
beginListen(String correlationId,
IMessageReceiver receiver)
Listens for incoming messages without blocking the current thread.
|
abstract void |
clear(String correlationId)
Clears component state.
|
abstract void |
close(String correlationId)
Closes component and frees used resources.
|
abstract void |
complete(MessageEnvelop message)
Permanently removes a message from the queue.
|
void |
configure(org.pipservices.commons.config.ConfigParams config)
Configures component by passing configuration parameters.
|
abstract void |
endListen(String correlationId)
Ends listening for incoming messages.
|
MessagingCapabilities |
getCapabilities()
Gets the queue capabilities
|
abstract Long |
getMessageCount()
Gets the current number of messages in the queue to be delivered.
|
String |
getName()
Gets the queue name
|
abstract boolean |
isOpen()
Checks if the component is opened.
|
abstract void |
listen(String correlationId,
IMessageReceiver receiver)
Listens for incoming messages and blocks the current thread until queue is
closed.
|
abstract void |
moveToDeadLetter(MessageEnvelop message)
Permanently removes a message from the queue and sends it to dead letter
queue.
|
void |
open(String correlationId)
Opens the component.
|
abstract 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.
|
abstract MessageEnvelop |
peek(String correlationId)
Peeks a single incoming message from the queue without removing it.
|
abstract List<MessageEnvelop> |
peekBatch(String correlationId,
int messageCount)
Peeks multiple incoming messages from the queue without removing them.
|
abstract MessageEnvelop |
receive(String correlationId,
long waitTimeout)
Receives an incoming message and removes it from the queue.
|
abstract void |
renewLock(MessageEnvelop message,
long lockTimeout)
Renews a lock on a message that makes it invisible from other receivers in
the queue.
|
abstract void |
send(String correlationId,
MessageEnvelop message)
Sends a message into the queue.
|
void |
sendAsObject(String correlationId,
String messageType,
Object message)
Sends an object into the queue.
|
void |
setReferences(org.pipservices.commons.refer.IReferences references)
Sets references to dependent components.
|
String |
toString()
Gets a string representation of the object.
|
protected String _name
protected String _kind
protected MessagingCapabilities _capabilities
protected Object _lock
protected org.pipservices.components.log.CompositeLogger _logger
protected org.pipservices.components.count.CompositeCounters _counters
protected org.pipservices.components.connect.ConnectionResolver _connectionResolver
protected org.pipservices.components.auth.CredentialResolver _credentialResolver
public MessageQueue()
public MessageQueue(String name)
name - (optional) a queue namepublic MessageQueue(String name, org.pipservices.commons.config.ConfigParams config)
name - (optional) a queue nameconfig - configuration parameterspublic void configure(org.pipservices.commons.config.ConfigParams config)
configure in interface org.pipservices.commons.config.IConfigurableconfig - configuration parameters to be set.public void setReferences(org.pipservices.commons.refer.IReferences references)
throws org.pipservices.commons.refer.ReferenceException
setReferences in interface org.pipservices.commons.refer.IReferenceablereferences - references to locate the component dependencies.org.pipservices.commons.refer.ReferenceException - when no found references.public String getName()
getName in interface IMessageQueuepublic MessagingCapabilities getCapabilities()
getCapabilities in interface IMessageQueuepublic abstract Long getMessageCount()
IMessageQueuegetMessageCount in interface IMessageQueuepublic abstract boolean isOpen()
isOpen in interface org.pipservices.commons.run.IOpenablepublic void open(String correlationId) throws org.pipservices.commons.errors.ApplicationException
open in interface org.pipservices.commons.run.IOpenablecorrelationId - (optional) transaction id to trace execution through
call chain.org.pipservices.commons.errors.ApplicationException - when error occured.public abstract void open(String correlationId, org.pipservices.components.connect.ConnectionParams connection, org.pipservices.components.auth.CredentialParams credential) throws org.pipservices.commons.errors.ApplicationException
correlationId - (optional) transaction id to trace execution through
call chain.connection - connection parameterscredential - credential parametersorg.pipservices.commons.errors.ApplicationException - when error occured.public abstract void close(String correlationId) throws org.pipservices.commons.errors.ApplicationException
close in interface org.pipservices.commons.run.IClosablecorrelationId - (optional) transaction id to trace execution through
call chain.org.pipservices.commons.errors.ApplicationException - when error occured.public abstract void clear(String correlationId) throws org.pipservices.commons.errors.ApplicationException
correlationId - (optional) transaction id to trace execution through
call chain.org.pipservices.commons.errors.ApplicationException - when error occured.public abstract void send(String correlationId, MessageEnvelop message) throws org.pipservices.commons.errors.ApplicationException
send in interface IMessageQueuecorrelationId - (optional) transaction id to trace execution through
call chain.message - a message envelop to be sent.org.pipservices.commons.errors.ApplicationException - when error occured.public void sendAsObject(String correlationId, String messageType, Object message) throws org.pipservices.commons.errors.ApplicationException
sendAsObject in interface IMessageQueuecorrelationId - (optional) transaction id to trace execution through
call chain.messageType - a message typemessage - an object value to be sentorg.pipservices.commons.errors.ApplicationException - when error occured.send(String, MessageEnvelop)public abstract MessageEnvelop peek(String correlationId) throws org.pipservices.commons.errors.ApplicationException
peek in interface IMessageQueuecorrelationId - (optional) transaction id to trace execution through
call chain.org.pipservices.commons.errors.ApplicationException - when error occured.public abstract List<MessageEnvelop> peekBatch(String correlationId, int messageCount) throws org.pipservices.commons.errors.ApplicationException
peekBatch in interface IMessageQueuecorrelationId - (optional) transaction id to trace execution through
call chain.messageCount - a maximum number of messages to peek.org.pipservices.commons.errors.ApplicationException - when error occured.public abstract MessageEnvelop receive(String correlationId, long waitTimeout) throws org.pipservices.commons.errors.ApplicationException
receive in interface IMessageQueuecorrelationId - (optional) transaction id to trace execution through
call chain.waitTimeout - a timeout in milliseconds to wait for a message to come.org.pipservices.commons.errors.ApplicationException - when error occured.public abstract void renewLock(MessageEnvelop message, long lockTimeout) throws org.pipservices.commons.errors.ApplicationException
renewLock in interface IMessageQueuemessage - a message to extend its lock.lockTimeout - a locking timeout in milliseconds.org.pipservices.commons.errors.ApplicationException - when error occured.public abstract void abandon(MessageEnvelop message) throws org.pipservices.commons.errors.ApplicationException
abandon in interface IMessageQueuemessage - a message to return.org.pipservices.commons.errors.ApplicationException - when error occured.public abstract void complete(MessageEnvelop message) throws org.pipservices.commons.errors.ApplicationException
complete in interface IMessageQueuemessage - a message to remove.org.pipservices.commons.errors.ApplicationException - when error occured.public abstract void moveToDeadLetter(MessageEnvelop message) throws org.pipservices.commons.errors.ApplicationException
moveToDeadLetter in interface IMessageQueuemessage - a message to be removed.org.pipservices.commons.errors.ApplicationException - when error occured.public abstract void listen(String correlationId, IMessageReceiver receiver) throws org.pipservices.commons.errors.ApplicationException
listen in interface IMessageQueuecorrelationId - (optional) transaction id to trace execution through
call chain.receiver - a receiver to receive incoming messages.org.pipservices.commons.errors.ApplicationException - when error occured.IMessageReceiverpublic void beginListen(String correlationId, IMessageReceiver receiver)
beginListen in interface IMessageQueuecorrelationId - (optional) transaction id to trace execution through
call chain.receiver - a receiver to receive incoming messages.IMessageReceiverpublic abstract void endListen(String correlationId) throws org.pipservices.commons.errors.ApplicationException
endListen in interface IMessageQueuecorrelationId - (optional) transaction id to trace execution through
call chain.org.pipservices.commons.errors.ApplicationException - when error occured.Copyright © 2018. All rights reserved.