nats-io / nats-architecture-and-design

Architecture and Design Docs
Apache License 2.0
170 stars 20 forks source link

Direct Message Multiple Values #250

Open scottf opened 6 months ago

scottf commented 6 months ago

Overview

Because of the way the server stacks values during republishes, the last value for each header field is the correct value for direct messages

Nats-Subject
Nats-Sequence
Nats-Last-Sequence
Nats-Time-Stamp
Nats-Stream

Clients and Tools

Example Unit Test

  1. Create a stream with configuration:

    name: "sbname"
    subjects: "sub.>"
    republish 
    src: ">" 
    dest: "$KV.sbname.>"
  2. Create a Key Value bucket with bucket name matching the stream name

    name: "sbname"
  3. Publish 3 different ways for coverage

    Connection Publish: Subject: "sub.1", Payload: "A"
    JetStream Publish: Subject: "sub.2", Payload: "B"
    Key Value Put to Bucket: Key: "sub.3", Value: "C"
  4. Retrieve values from the bucket.

KeyValueEntry kve1 = kv.get(publishSubject1);
assertEquals("sbname", kve1.getBucket());
assertEquals("sub.1", kve1.getKey());
assertEquals("A", kve1.getValueAsString());

KeyValueEntry kve2 = kv.get(publishSubject2);
assertEquals("sbname", kve2.getBucket());
assertEquals("sub.2", kve2.getKey());
assertEquals("B", kve2.getValueAsString());

KeyValueEntry kve3 = kv.get(publishSubject3);
assertEquals("sbname", kve3.getBucket());
assertEquals("sub.3", kve3.getKey());
assertEquals("C", kve3.getValueAsString());

Other Tasks

Client authors please update with your progress. If you open issues in your own repositories as a result of this request, please link them to this one by pasting the issue URL in a comment or main issue description.