Gcloud::Pubsub::Message

Message

Represents a Pub/Sub Message.

Message objects are created by Gcloud::Pubsub::Topic#publish. Gcloud::Pubsub::Subscription#pull returns an array of ReceivedMessage objects, each of which contains a Message object. Each ReceivedMessage object can be acknowledged and/or delayed.

require "gcloud"

gcloud = Gcloud.new
pubsub = gcloud.pubsub

# Publish a message
topic = pubsub.topic "my-topic"
message = topic.publish "new-message"
puts message.data #=>  "new-message"

# Pull a message
sub = pubsub.subscription "my-topic-sub"
received_message = sub.pull.first
puts received_message.message.data #=>  "new-message"

Methods

Public Class Methods

new(data = nil, attributes = {})

Create an empty Message object. This can be used to publish several messages in bulk.

Public Instance Methods

attributes()

The received attributes.

data()

The received data.

message_id()

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

Also aliased as: msg_id

msg_id()

Alias for: message_id