struct

NATS::JetStream::Message

Inherits Struct / Value / Object

A NATS::JetStream::Message is very similar to a NATS::Message in that it represents a piece of information published by a NATS client (not necessarily this NATS client, though). This Message type contains more information, however, such as information about the stream and consumer it came from, how many times it's been delivered, etc.

Constructors

new(stream : String, consumer : String, delivered_count : Int64, stream_seq : Int64, consumer_seq : Int64, timestamp : Time, pending : Int64, data_string : String, subject : String, reply_to : String, headers : HTTP::Headers | Nil)
Source
new(msg : NATS::Message)

Instantiate a NATS::JetStream::Message based on a NATS::Message. Used by JetStream subscriptions to build JetStream::Message instances, since JetStream is a layer on top of core NATS.

Source

Instance methods

body

The message payload, encoded as binary. If you need text, use data_string.

jetstream.subscribe consumer do |msg|
  data = MessagePack.parse(msg.data)
end
Source
consumer

The name of the consumer we received this message from

Source
consumer_seq

The position of this message within its consumer, including redeliveries

Source
data

The message payload, encoded as binary. If you need text, use data_string.

jetstream.subscribe consumer do |msg|
  data = MessagePack.parse(msg.data)
end
Source
data_string

The message payload, encoded as a UTF-8 string.

Source
delivered_count

The number of times this particular message has been delivered by this consumer, starting at 1

Source
headers

Any headers that were published with this message, including ones interpreted by the NATS server, such as Nats-Msg-Id for message deduplication.

Source
pending

How many messages follow this message for this consumer

Source
reply_to

The subject used for acknowledging this message

Source
stream

The name of the stream this message was consumed from

Source
stream_seq

The position of this message within its stream

Source
subject

The original subject this message was published to, which can be (and most likely is) different from the subject it was delivered to

Source
timestamp

When this message was originally published

Source

Nested types