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.IClosable
Interface 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
.See
MessagingCapabilities
,MessageEnvelope
-
abandon
(message: pip_services3_messaging.queues.MessageEnvelope.MessageEnvelope)¶ 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: Optional[str], receiver: <module 'pip_services3_messaging.queues.IMessageReceiver' from '/pip_services3_messaging/queues/IMessageReceiver.py'>)¶ 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: pip_services3_messaging.queues.MessageEnvelope.MessageEnvelope)¶ 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: Optional[str])¶ 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
() → <module ‘pip_services3_messaging.queues.MessagingCapabilities’ from ‘/pip_services3_messaging/queues/MessagingCapabilities.py’>¶ Gets the queue capabilities
- Returns
the queue’s capabilities object.
-
listen
(correlation_id: Optional[str], receiver: <module 'pip_services3_messaging.queues.IMessageReceiver' from '/pip_services3_messaging/queues/IMessageReceiver.py'>)¶ 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: pip_services3_messaging.queues.MessageEnvelope.MessageEnvelope)¶ Permanently removes a message from the queue and sends it to dead letter queue.
- Parameters
message – a message to be removed.
-
peek
(correlation_id: Optional[str]) → pip_services3_messaging.queues.MessageEnvelope.MessageEnvelope¶ 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: Optional[str], message_count: int) → List[pip_services3_messaging.queues.MessageEnvelope.MessageEnvelope]¶ 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
() → int¶ Reads the current number of messages in the queue to be delivered.
- Returns
a number of messages
-
receive
(correlation_id: Optional[str], wait_timeout: int) → pip_services3_messaging.queues.MessageEnvelope.MessageEnvelope¶ 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: pip_services3_messaging.queues.MessageEnvelope.MessageEnvelope, lock_timeout: int)¶ 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: Optional[str], envelop: pip_services3_messaging.queues.MessageEnvelope.MessageEnvelope)¶ 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: Optional[str], message_type: str, message: Any)¶ Sends an object into the queue. Before sending the object is converted into JSON string and wrapped in a
MessageEnvelope
.- Parameters
correlation_id – (optional) transaction id to trace execution through call chain.
message_type – a message type
message – an object value to be sent
-