Gcloud::Pubsub::ReceivedMessage

ReceivedMessage

Represents a Pub/Sub Message that can be acknowledged or delayed.

require "gcloud"

gcloud = Gcloud.new
pubsub = gcloud.pubsub

sub = pubsub.subscription "my-topic-sub"
received_message = sub.pull.first
if received_message
  puts received_message.message.data
  received_message.acknowledge!
end

Methods

Public Instance Methods

ack!()

Alias for: acknowledge!

ack_id()

The acknowledgment ID for the message.

acknowledge!()

Acknowledges receipt of the message.

Example

require "gcloud"

gcloud = Gcloud.new
pubsub = gcloud.pubsub

sub = pubsub.subscription "my-topic-sub"
received_message = sub.pull.first
if received_message
  puts received_message.message.data
  received_message.acknowledge!
end
Also aliased as: ack!

attributes()

The received message's attributes.

data()

The received message's data.

delay!(new_deadline)

Modifies the acknowledge deadline for the message.

This indicates that more time is needed to process the message, or to make the message available for redelivery.

Parameters

deadline

The new ack deadline in seconds from the time this request is sent to the Pub/Sub system. Must be >= 0. For example, if the value is 10, the new ack deadline will expire 10 seconds after the call is made. Specifying 0 may immediately make the message available for another pull request. (Integer)

Example

require "gcloud"

gcloud = Gcloud.new
pubsub = gcloud.pubsub

sub = pubsub.subscription "my-topic-sub"
received_message = sub.pull.first
if received_message
  puts received_message.message.data
  # Delay for 2 minutes
  received_message.delay! 120
end

message()

The received message.

Also aliased as: msg

message_id()

The ID of the received message, assigned by the server at publication time. Guaranteed to be unique within the topic.

Also aliased as: msg_id

msg()

Alias for: message

msg_id()

Alias for: message_id