From be2f1ba96e36191089f063811283af61215ab7e4 Mon Sep 17 00:00:00 2001 From: scottf Date: Tue, 29 Apr 2025 12:26:10 -0400 Subject: [PATCH 1/2] [EDIT] ADR-22 Integration and Orbit notes --- adr/ADR-22.md | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/adr/ADR-22.md b/adr/ADR-22.md index 5cfcfd20..67d48b73 100644 --- a/adr/ADR-22.md +++ b/adr/ADR-22.md @@ -7,6 +7,11 @@ | Status | Partially Implemented | | Tags | jetstream, client | +| Revision | Date | Author | Info | +|----------|------------|----------|-----------------------------| +| 1 | 2022-03-18 | @wallyqs | Initial design | +| 2 | 2024-03-06 | @scottf | Integration and Orbit notes | + ## Motivation When the NATS Server is running with JetStream on cluster mode, there @@ -16,6 +21,10 @@ try to mitigate these failures, retries can be added into JetStream enabled clients to attempt to publish the message to JetStream once it is ready again. +#### Client Integration + +Although an implementation is provided directly in the GO client, it is preferred that this functionality is built in Orbit or similar, as an extension/library. + ## Implementation A `no responders available` error uses the 503 status header to signal @@ -26,14 +35,14 @@ JetStream service was not ready at the moment of publishing, the server will send to the requestor a 503 status message right away. To improve robustness of producing messages to JetStream, a client can -back off for a a bit and then try to send the message again later. +back off for a bit and then try to send the message again later. By default, the Go client waits for `250ms` and will retry 2 times sending the message (so that in total it would have attempted to send the message 3 times). -Below can be found an example implementation using the `Request` API +Below can be found an example implementation using the `Request` API from the Go client: - + ```go // Stream that persists messages sent to 'foo' js.AddStream(&nats.StreamConfig{Name: "foo"}) @@ -68,7 +77,7 @@ for range time.NewTicker(100 * time.Millisecond).C { ## Errors -After exhausting the number of attempts, the result should either be a timeout error +After exhausting the number of attempts, the result should either be a timeout error in case the deadline expired or a `nats: no response from stream` error if the error from the last attempt was still a `no responders error`. @@ -107,3 +116,7 @@ if err != nil { log.Println("Pub Error", err) } ``` + +## Orbit / Implementations + +[Java JetStream Publish Extentions](https://github.com/synadia-io/orbit.java/tree/main/js-publish-extensions) \ No newline at end of file From 407bdf902ab71a8674a7c4819efab4ba668925fd Mon Sep 17 00:00:00 2001 From: Scott Fauerbach Date: Tue, 29 Apr 2025 12:56:10 -0400 Subject: [PATCH 2/2] Update adr/ADR-22.md Co-authored-by: Alex Bozhenko --- adr/ADR-22.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adr/ADR-22.md b/adr/ADR-22.md index 67d48b73..b8b7d84c 100644 --- a/adr/ADR-22.md +++ b/adr/ADR-22.md @@ -23,7 +23,7 @@ is ready again. #### Client Integration -Although an implementation is provided directly in the GO client, it is preferred that this functionality is built in Orbit or similar, as an extension/library. +Although an implementation is provided directly in the GO client, it is preferred that this functionality is built in [Orbit](https://www.synadia.com/blog/orbit-and-the-future-of-the-clients) or similar, as an extension/library. ## Implementation