Message

class amqpstorm.Message(channel, auto_decode=True, **message)[source]

RabbitMQ Message object.

static create(channel, body, properties=None)[source]

Create a new Message.

Parameters:
  • channel (Channel) – AMQPStorm Channel
  • body (bytes|str|unicode) – Message payload
  • properties (dict) – Message properties
Return type:

Message

body

Return the Message Body.

If auto_decode is enabled, the body will automatically be decoded using decode(‘utf-8’) if possible.
Return type:bytes|str|unicode
channel

Return the Channel used by this message.

Return type:Channel
method

Return the Message Method.

If auto_decode is enabled, the any strings will automatically be decoded using decode(‘utf-8’) if possible.
Return type:dict
properties

Returns the Message Properties.

If auto_decode is enabled, the any strings will automatically be decoded using decode(‘utf-8’) if possible.
Return type:dict
ack()[source]

Acknowledge Message.

Raises:
  • AMQPInvalidArgument – Invalid Parameters
  • AMQPChannelError – Raises if the channel encountered an error.
  • AMQPConnectionError – Raises if the connection encountered an error.
Returns:

nack(requeue=True)[source]

Negative Acknowledgement.

Raises:
  • AMQPInvalidArgument – Invalid Parameters
  • AMQPChannelError – Raises if the channel encountered an error.
  • AMQPConnectionError – Raises if the connection encountered an error.
Parameters:

requeue (bool) –

reject(requeue=True)[source]

Reject Message.

Raises:
  • AMQPInvalidArgument – Invalid Parameters
  • AMQPChannelError – Raises if the channel encountered an error.
  • AMQPConnectionError – Raises if the connection encountered an error.
Parameters:

requeue (bool) – Requeue the message

publish(routing_key, exchange='', mandatory=False, immediate=False)[source]

Publish Message.

Parameters:
  • routing_key (str) – Message routing key
  • exchange (str) – The exchange to publish the message to
  • mandatory (bool) – Requires the message is published
  • immediate (bool) – Request immediate delivery
Raises:
  • AMQPInvalidArgument – Invalid Parameters
  • AMQPChannelError – Raises if the channel encountered an error.
  • AMQPConnectionError – Raises if the connection encountered an error.
Return type:

bool|None

app_id

Get AMQP Message attribute: app_id.

Returns:
message_id

Get AMQP Message attribute: message_id.

Returns:
content_encoding

Get AMQP Message attribute: content_encoding.

Returns:
content_type

Get AMQP Message attribute: content_type.

Returns:
correlation_id

Get AMQP Message attribute: correlation_id.

Returns:
delivery_mode

Get AMQP Message attribute: delivery_mode.

Returns:
timestamp

Get AMQP Message attribute: timestamp.

Returns:
priority

Get AMQP Message attribute: priority.

Returns:
reply_to

Get AMQP Message attribute: reply_to.

Returns:
json()[source]

Deserialize the message body, if it is JSON.

Returns: