Class Message (2.13.0)

Message objects provide a simple interface for users to get message data and acknowledge the message.

Package

@google-cloud/pubsub!

Constructors

(constructor)(sub, { ackId, message, deliveryAttempt })

constructor(sub: Subscriber, { ackId, message, deliveryAttempt }: google.pubsub.v1.IReceivedMessage);

Constructs a new instance of the Message class

Parameters
NameDescription
sub Subscriber

The parent subscriber.

{ ackId, message, deliveryAttempt } google.pubsub.v1.IReceivedMessage

Properties

ackId

ackId: string;
Property Value
TypeDescription
string

attributes

attributes: {
        [key: string]: string;
    };
Property Value
TypeDescription
{ [key: string]: string; }

data

data: Buffer;
Property Value
TypeDescription
Buffer

deliveryAttempt

deliveryAttempt: number;
Property Value
TypeDescription
number

id

id: string;
Property Value
TypeDescription
string

length

get length(): number;

The length of the message data.

{number}

Property Value
TypeDescription
number

orderingKey

orderingKey?: string;
Property Value
TypeDescription
string

publishTime

publishTime: PreciseDate;
Property Value
TypeDescription
PreciseDate

received

received: number;
Property Value
TypeDescription
number

Methods

ack()

ack(): void;

Acknowledges the message.

Returns
TypeDescription
void

modAck(deadline)

modAck(deadline: number): void;

Modifies the ack deadline.

Parameter
NameDescription
deadline number

The number of seconds to extend the deadline.

Returns
TypeDescription
void

nack()

nack(): void;

Removes the message from our inventory and schedules it to be redelivered.

Returns
TypeDescription
void