Message
Message objects provide a simple interface for users to get message data and acknowledge the message.
Properties
ackId
string
This ID is used to acknowledge the message.
attributes
object
Optional attributes for this message.
data
Buffer
The message data as a Buffer.
id
string
ID of the message, assigned by the server when the message is published. Guaranteed to be unique within the topic.
length
number
The length of the message data.
publishTime
The time at which the message was published.
received
number
The time at which the message was recieved by the subscription.
Methods
ack
ack()
Acknowledges the message.
Example
subscription.on('message', message => {
message.ack();
});
nack
nack(delay)
Removes the message from our inventory and schedules it to be redelivered. If the delay parameter is unset, it will be redelivered immediately.
Parameter |
|
---|---|
delay |
Optional number The desired time to wait before the redelivery occurs. |
Examples
subscription.on('message', message => {
message.nack();
});
Specify a delay to redeliver the message
subscription.on('message', message => {
message.nack(60); // redeliver in 1 minute
});