nats-architecture-and-design icon indicating copy to clipboard operation
nats-architecture-and-design copied to clipboard

Direct Message Multiple Values

Open scottf opened this issue 1 year ago • 0 comments

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

  • [ ] Go @piotrpio
  • [x] Java @scottf https://github.com/nats-io/nats.java/pull/1016 and https://github.com/nats-io/nats.java/pull/1099
  • [X] JavaScript @aricart https://github.com/nats-io/nats.deno/issues/586
  • [x] .Net @scottf https://github.com/nats-io/nats.net/pull/830 and https://github.com/nats-io/nats.net/pull/879
  • [ ] C @levb
  • [ ] Python @wallyqs
  • [ ] Ruby @wallyqs
  • [ ] Rust @Jarema @caspervonb
  • [x] .Net V2 @mtmk https://github.com/nats-io/nats.net.v2/pull/512

Example Unit Test

  1. Create a stream with configuration:
name: "sbname"
subjects: "sub.>"
republish 
    src: ">" 
    dest: "$KV.sbname.>"
  1. Create a Key Value bucket with bucket name matching the stream name
name: "sbname"
  1. 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"
  1. 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

  • [ ] docs.nats.io updated @bruth
  • [ ] Update ADR to Implemented
  • [ ] Update client features spreadsheet

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.

scottf avatar Oct 18 '23 15:10 scottf