Constructor
new Message(sub, message)
Parameters:
Name | Type | Description |
---|---|---|
sub |
Subscriber |
The parent subscriber. |
message |
object |
The raw message response. |
Example
subscription.on('message', message => {
// {
// ackId: 'RUFeQBJMJAxESVMrQwsqWBFOBCEhPjA',
// attributes: {key: 'value'},
// data: Buffer.from('Hello, world!'),
// id: '1551297743043',
// orderingKey: 'ordering-key',
// publishTime: new PreciseDate('2019-02-27T20:02:19.029534186Z'),
// received: 1551297743043,
// length: 13
// }
});
Members
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.
deliveryAttempt :number
Delivery attempt counter is 1 + (the sum of number of NACKs and number of ack_deadline exceeds) for this message.
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.
orderingKey :string
Identifies related messages for which publish order should be respected.
If a Subscription
has enableMessageOrdering
set to true
, messages
published with the same orderingKey
value will be delivered to
subscribers in the order in which they are received by the Pub/Sub
system.
EXPERIMENTAL: This feature is part of a closed alpha release. This API might be changed in backward-incompatible ways and is not recommended for production use. It is not subject to any SLA or deprecation policy.
publishTime :external:PreciseDate
The time at which the message was published.
received :number
The time at which the message was recieved by the subscription.
Methods
ack()
Acknowledges the message.
nack()
Removes the message from our inventory and schedules it to be redelivered.