struct NATS::JetStream::Message
- NATS::JetStream::Message
- Struct
- Value
- Object
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.crConstructors
- .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))
- 
        .new(msg : NATS::Message)
        
          Instantiate a NATS::JetStream::Messagebased on aNATS::Message.
Instance Method Summary
- 
        #body : Bytes
        
          The original body of the message, encoded as binary. 
- 
        #consumer : String
        
          The name of the consumer we received this message from 
- 
        #consumer_seq : Int64
        
          The position of this message within its consumer, including redeliveries 
- 
        #delivered_count : Int64
        
          The number of times this particular message has been delivered by this consumer, starting at 1 
- 
        #headers : Headers
        
          Any headers that were published with this message, including ones interpreted by the NATS server, such as Nats-Msg-Idfor message deduplication.
- 
        #pending : Int64
        
          How many messages follow this message for this consumer 
- 
        #reply_to : String
        
          The subject used for acknowledging this message 
- 
        #stream : String
        
          The name of the stream this message was consumed from 
- 
        #stream_seq : Int64
        
          The position of this message within its stream 
- 
        #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 
- 
        #timestamp : Time
        
          When this message was originally published 
Constructor Detail
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.
Instance Method Detail
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)
  # ...
endThe number of times this particular message has been delivered by this consumer, starting at 1
Any headers that were published with this message, including ones
interpreted by the NATS server, such as Nats-Msg-Id for message
deduplication.
The original subject this message was published to, which can be (and most likely is) different from the subject it was delivered to