Home | Trees | Indices | Help |
---|
|
object --+ | Messenger
The Messenger class defines a high level interface for sending and receiving Messages. Every Messenger contains a single logical queue of incoming messages and a single logical queue of outgoing messages. These messages in these queues may be destined for, or originate from, a variety of addresses.
An address has the following form:
[ amqp[s]:// ] [user[:password]@] domain [/[name]]
Where domain can be one of:
host | host:port | ip | ip:port | name
The following are valid examples of addresses:
The Messenger class works in conjuction with the Message class. The Message class is a mutable holder of message content. The put method will encode the content in a given Message object into the outgoing message queue leaving that Message object free to be modified or discarded without having any impact on the content in the outgoing queue.
>>> message = Message() >>> for i in range(3): ... message.address = "amqp://host/queue" ... message.subject = "Hello World %i" % i ... messenger.put(message) >>> messenger.send()
Similarly, the get method will decode the content in the incoming message queue into the supplied Message object.
>>> message = Message() >>> messenger.recv(10): >>> while messenger.incoming > 0: ... messenger.get(message) ... print message.subject Hello World 0 Hello World 1 Hello World 2
Instance Methods | |||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
Inherited from |
Class Variables | |
certificate = property(_get_certificate, _set_certificate, doc
|
|
private_key = property(_get_private_key, _set_private_key, doc
|
|
password = property(_get_password, _set_password, doc=
|
|
trusted_certificates = property(_get_trusted_certificates, _se
|
|
timeout = property(_get_timeout, _set_timeout, doc=
|
|
blocking = property(_is_blocking, _set_blocking)
|
|
incoming_window = property(_get_incoming_window, _set_incoming
|
|
outgoing_window = property(_get_outgoing_window, _set_outgoing
|
Properties | |
Inherited from |
Method Details |
Construct a new Messenger with the given name. The name has global scope. If a NULL name is supplied, a uuid.UUID based name will be chosen.
|
The name of the Messenger.
|
Transitions the Messenger to an active state. A Messenger is initially created in an inactive state. When inactive a Messenger will not send or receive messages from its internal queues. A Messenger must be started before calling send or recv. |
Transitions the Messenger to an inactive state. An inactive Messenger will not send or receive messages from its internal queues. A Messenger should be stopped before being discarded to ensure a clean shutdown handshake occurs on any internally managed connections. |
|
Subscribes the Messenger to messages originating from the specified source. The source is an address as specified in the Messenger introduction with the following addition. If the domain portion of the address begins with the '~' character, the Messenger will interpret the domain as host/port, bind to it, and listen for incoming messages. For example "~0.0.0.0", "amqp://~0.0.0.0", and "amqps://~0.0.0.0" will all bind to any local interface and listen for incoming messages with the last variant only permitting incoming SSL connections.
|
Places the content contained in the message onto the outgoing queue of the Messenger. This method will never block, however it will send any unblocked Messages in the outgoing queue immediately and leave any blocked Messages remaining in the outgoing queue. The send call may be used to block until the outgoing queue is empty. The outgoing property may be used to check the depth of the outgoing queue.
|
Gets the last known remote state of the delivery associated with the given tracker.
|
Blocks until the outgoing queue is empty or the operation times out. The timeout property controls how long a Messenger will block before timing out. |
Receives up to n messages into the incoming queue of the Messenger. If n is not specified, Messenger will receive as many messages as it can buffer internally. This method will block until at least one message is available or the operation times out. |
Moves the message from the head of the incoming message queue into the supplied message object. Any content in the message will be overwritten.
|
Accepts messages retreived from the incoming message queue.
|
Rejects messages retreived from the incoming message queue.
|
The outgoing queue depth.
|
The incoming queue depth.
|
Class Variable Details |
certificate
|
private_key
|
password
|
trusted_certificates
|
timeout
|
incoming_window
|
outgoing_window
|
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Fri Sep 13 10:11:35 2013 | http://epydoc.sourceforge.net |