Producer(channel, exchange=None, routing_key=None, serializer=None, auto_declare=None, compression=None, on_return=None)
- channel – Connection or channel.
- exchange – Optional default exchange.
- routing_key – Optional default routing key.
- serializer – Default serializer. Default is “json”.
- compression – Default compression method. Default is no compression.
- auto_declare – Automatically declare the default exchange
at instantiation. Default is
- on_return – Callback to call for undeliverable messages,
when the mandatory or immediate arguments to
publish()is used. This callback needs the following signature: (exception, exchange, routing_key, message). Note that the producer needs to drain events to use this feature.
By default the exchange is declared at instantiation. If you want to declare manually then you can set this to
Default compression method. Disabled by default.
Declare the exchange.
This happens automatically at instantiation if
maybe_declare(entity, retry=False, **retry_policy)
Declare the exchange if it hasn’t already been declared during this session.
Basic return callback.
publish(body, routing_key=None, delivery_mode=None, mandatory=False, immediate=False, priority=0, content_type=None, content_encoding=None, serializer=None, headers=None, compression=None, exchange=None, retry=False, retry_policy=None, declare=, expiration=None, **properties)
Publish message to the specified exchange.
- body – Message body.
- routing_key – Message routing key.
- delivery_mode – See
- mandatory – Currently not supported.
- immediate – Currently not supported.
- priority – Message priority. A number between 0 and 9.
- content_type – Content type. Default is auto-detect.
- content_encoding – Content encoding. Default is auto-detect.
- serializer – Serializer to use. Default is auto-detect.
- compression – Compression method to use. Default is none.
- headers – Mapping of arbitrary headers to pass along with the message body.
- exchange – Override the exchange. Note that this exchange must have been declared.
- declare – Optional list of required entities that must
have been declared before publishing the message. The entities
will be declared using
- retry – Retry publishing, or declaring entities if the connection is lost.
- retry_policy – Retry configuration, this is the keywords
- expiration – A TTL in seconds can be specified per message. Default is no expiration.
- **properties – Additional message properties, see AMQP spec.
Default routing key.
Default serializer to use. Default is JSON.