Message – an NSQ message¶
- class nsq.Message(id, body, timestamp, attempts)¶
A class representing a message received from nsqd.
If you want to perform asynchronous message processing use the nsq.Message.enable_async() method, pass the message around, and respond using the appropriate instance method.
Parameters: - id (string) – the ID of the message
- body (string) – the raw message body
- timestamp (int) – the timestamp the message was produced
- attempts (int) – the number of times this message was attempted
- enable_async()¶
Enables asynchronous processing for this message.
nsq.Reader will not automatically respond to the message upon return of message_handler.
- finish()¶
Respond to nsqd that you’ve processed this message successfully (or would like to silently discard it).
- has_responded()¶
Returns whether or not this message has been responded to.
- is_async()¶
Returns whether or not asynchronous processing has been enabled.
- requeue(**kwargs)¶
Respond to nsqd that you’ve failed to process this message successfully (and would like it to be requeued).
Parameters: - backoff (bool) – whether or not nsq.Reader should apply backoff handling
- delay (int) – the amount of time (in seconds) that this message should be delayed
- touch()¶
Respond to nsqd that you need more time to process the message.