struct NATS::JetStream::Message

Overview

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.

Defined in:

jetstream/message.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(stream : String, consumer : String, delivered_count : Int64, stream_seq : Int64, consumer_seq : Int64, timestamp : Time, pending : Int64, body : Slice(UInt8), subject : String, reply_to : String, headers : Nil | Hash(String, String)) #

[View source]
def self.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.


[View source]

Instance Method Detail

def body : Bytes #

The original body of the message, encoded as binary. If you need text, wrap the body in a String.

jetstream.subscribe consumer do |msg|
  body_string = String.new(msg.body)

  # ...
end

[View source]
def consumer : String #

The name of the consumer we received this message from


[View source]
def consumer_seq : Int64 #

The position of this message within its consumer, including redeliveries


[View source]
def delivered_count : Int64 #

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


[View source]
def headers : Headers #

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


[View source]
def pending : Int64 #

How many messages follow this message for this consumer


[View source]
def reply_to : String #

The subject used for acknowledging this message


[View source]
def stream : String #

The name of the stream this message was consumed from


[View source]
def stream_seq : Int64 #

The position of this message within its stream


[View source]
def subject : String #

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


[View source]
def timestamp : Time #

When this message was originally published


[View source]