Message
- class amqpstorm.Message[source]
RabbitMQ Message.
e.g.
# Message Properties. properties = { 'content_type': 'text/plain', 'expiration': '3600', 'headers': {'key': 'value'}, } # Create a new message. message = Message.create(channel, 'Hello RabbitMQ!', properties) # Publish the message to a queue called, 'my_queue'. message.publish('my_queue')
- Parameters:
- __init__(channel: Channel | None, body: bytes | str | None = None, method: dict[str, Any] | None = None, properties: dict[str, Any] | None = None, auto_decode: bool = True) None[source]
- static create(channel: Channel, body: bytes | str, properties: dict[str, Any] | None = None) Message[source]
Create a new Message.
- property body: bytes | str | None
Return the Message Body.
If auto_decode is enabled, the body will automatically be decoded using decode(‘utf-8’) if possible.
- property method: dict[str, Any] | None
Return the Message Method.
If auto_decode is enabled, all strings will automatically be decoded using decode(‘utf-8’) if possible.
- Return type:
- property properties: dict[str, Any]
Returns the Message Properties.
If auto_decode is enabled, all strings will automatically be decoded using decode(‘utf-8’) if possible.
- Return type:
- ack() None[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: bool = True) None[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) – Re-queue the message
- reject(requeue: bool = True) None[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) – Re-queue the message
- publish(routing_key: str, exchange: str = '', mandatory: bool = False, immediate: bool = False) bool | None[source]
Publish Message.
- Parameters:
- Raises:
AMQPInvalidArgument – Invalid Parameters
AMQPChannelError – Raises if the channel encountered an error.
AMQPConnectionError – Raises if the connection encountered an error.
- Return type:
bool,None