diff --git a/adr/ADR-22.md b/adr/ADR-22.md index 5cfcfd20..b8b7d84c 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](https://www.synadia.com/blog/orbit-and-the-future-of-the-clients) 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