pip_services3_messaging.queues.IMessageQueue module¶
pip_services3_messaging.queues.IMessageQeueue¶
Interface for message queues.
| copyright: | Conceptual Vision Consulting LLC 2018-2019, see AUTHORS for more details. |
|---|---|
| license: | MIT, see LICENSE for more details. |
-
class
pip_services3_messaging.queues.IMessageQueue.IMessageQueue¶ Bases:
pip_services3_commons.run.IOpenable.IOpenable,pip_services3_commons.run.IClosable.IClosableInterface for asynchronous message queues.
Not all queues may implement all the methods. Attempt to call non-supported method will result in NotImplemented exception. To verify if specific method is supported consult with [[MessagingCapabilities]].
-
abandon(message)¶ Returnes message into the queue and makes it available for all subscribers to receive it again. This method is usually used to return a message which could not be processed at the moment to repeat the attempt. Messages that cause unrecoverable errors shall be removed permanently or/and send to dead letter queue.
Parameters: message – a message to return.
-
begin_listen(correlation_id, receiver)¶ Listens for incoming messages without blocking the current thread.
Parameters: - correlation_id – (optional) transaction id to trace execution through call chain.
- receiver – a receiver to receive incoming messages.
-
complete(message)¶ Permanently removes a message from the queue. This method is usually used to remove the message after successful processing.
Parameters: message – a message to remove.
-
end_listen(correlation_id)¶ Ends listening for incoming messages. When this method is call [[listen]] unblocks the thread and execution continues.
Parameters: correlation_id – (optional) transaction id to trace execution through call chain.
-
get_capabilities()¶ Gets the queue capabilities
Returns: the queue’s capabilities object.
-
get_name()¶ Gets the queue name
Returns: the queue name.
-
listen(correlation_id, receiver)¶ Listens for incoming messages and blocks the current thread until queue is closed.
Parameters: - correlation_id – (optional) transaction id to trace execution through call chain.
- receiver – a receiver to receive incoming messages.
-
move_to_dead_letter(message)¶ Permanently removes a message from the queue and sends it to dead letter queue.
Parameters: message – a message to be removed.
-
peek(correlation_id)¶ Peeks a single incoming message from the queue without removing it. If there are no messages available in the queue it returns null.
Parameters: correlation_id – (optional) transaction id to trace execution through call chain. Returns: a message object.
-
peek_batch(correlation_id, message_count)¶ Peeks multiple incoming messages from the queue without removing them. If there are no messages available in the queue it returns an empty list.
Parameters: - correlation_id – (optional) transaction id to trace execution through call chain.
- message_count – a maximum number of messages to peek.
Returns: a list of message objects.
-
read_message_count()¶ Reads the current number of messages in the queue to be delivered.
Returns: a number of messages
-
receive(correlation_id, wait_timeout)¶ Receives an incoming message and removes it from the queue.
Parameters: - correlation_id – (optional) transaction id to trace execution through call chain.
- wait_timeout – a timeout in milliseconds to wait for a message to come.
Returns: a message object.
-
renew_lock(message, lock_timeout)¶ Renews a lock on a message that makes it invisible from other receivers in the queue. This method is usually used to extend the message processing time.
Parameters: - message – a message to extend its lock.
- lock_timeout – a locking timeout in milliseconds.
-
send(correlation_id, envelop)¶ Sends a message into the queue.
Parameters: - correlation_id – (optional) transaction id to trace execution through call chain.
- envelop – a message envelop to be sent.
-
send_as_object(correlation_id, message_type, message)¶ Sends an object into the queue. Before sending the object is converted into JSON string and wrapped in a [[MessageEnvelop]].
Parameters: - correlation_id – (optional) transaction id to trace execution through call chain.
- message_type – a message type
- message – an object value to be sent
-