Skip to content

Message ​

pythonpython
from rillkit import Message

One stream entry as seen by a handler or middleware. RillKit creates it; you normally only read from it.

A handler receives a Message when a parameter is annotated Message, or is named msg or message with no annotation. See Consuming.

Attributes ​

AttributeTypeDescription
idstrThe entry id, for example 1793094479536-0.
streamStreamThe stream (with its group and codec) this message came from.
rawdict[str, str]All fields of the entry as text, including data.
deliveriesintHow many times Redis has delivered this entry to the group, counting the current one. 1 on the first delivery.
consumerstrName of the consumer that holds the message.
ackedboolTrue once the message has been acknowledged (or dead-lettered).
nackedboolTrue after nack() until it is acked.
rejectedboolTrue after reject().
reject_reasonOptional[str]The reason passed to reject().
errorOptional[BaseException]The exception the handler raised, set only when it failed with an ordinary exception.
bodyAnyProperty: the decoded payload (a dict for a JSON object). Decoded on first access and cached. Raises DecodeError if there is no data field or it cannot be decoded.

You can also attach your own attributes, for example per-message state in middleware (msg.started = ...).

Methods ​

ack() ​

Acknowledges the message with XACK so it leaves the pending list and is never redelivered. Calling it twice is harmless. Sets acked = True and nacked = False.

nack() ​

Marks the message failed so it stays pending and is retried after claim_idle_ms, or dead-lettered if retries are used up. Does nothing if the message was already acked. Sets nacked = True.

reject(reason=None) ​

Skips the remaining retries. When the handler finishes, RillKit copies the entry to the DLQ with reason as x-error and acks it. Works under every AckPolicy. Sets rejected = True and nacked = False. A later exception or nack() in the same handler does not undo it.

repr ​

Message(id='1793094479536-0', stream='orders', deliveries=1)

RillKit is released under the MIT License.