davsclaus opened a new pull request, #30736: URL: https://github.com/apache/camel/pull/30736
_Claude Code on behalf of davsclaus_ JIRA: https://issues.apache.org/jira/browse/CAMEL-27198 With `jetstreamEnabled=true`, the producer had three problems. `requestTimeout` did not reach jnats, so a synchronous publish waited the connection timeout (2 s). `jetstreamName` was never used, because `jsm.jetStream()` never returns null. A timeout failed with the message "null". ## Changes - The JetStream context is created once in `doStart()`, with `JetStreamOptions.requestTimeout(requestTimeout)`. The connection object stays the same when jnats reconnects, and a restarted producer creates a new context. - With `jetstreamAsync=true`, jnats 2.26.4 ignores `JetStreamOptions` for `publishAsync`: it gives up on the acknowledgement after `requestCleanupInterval` (to twice that). The option docs and the error message say so. - `jetstreamName`: the producer now matches the consumer. At start it looks up the stream, and creates it with the topic as subject when it is missing. It does not create it when another stream already takes in the subject, so existing setups do not fail with "subjects overlap". A failure to check or create the stream logs a WARN and the producer still starts, as the consumer does. Before, such a setup failed every send with `503 No Responders`. The dead `addStream` branch is removed. - A timeout now says "No acknowledgement from JetStream for subject X within N ms". When jnats cancels the request, the message says so and names `requestCleanupInterval`. The `CancellationException` from jnats comes wrapped in an `ExecutionException` (the PublishAck future is composed on the reply future), so it was caught, but reported as a raw `java.util.concurrent.CancellationException`. Both forms are handled now. - The descriptions of `jetstreamName` and `requestTimeout` are fixed. The `jetstreamName` label stays `common`, because both sides use it now. There is a new "JetStream producer" section in the component doc, and an upgrade guide entry: the stream creation, and the synchronous wait that is now `requestTimeout` (20 s) instead of 2 s. ## Tests - `NatsProducerJetStreamTest` (new, fakes, no Docker): 8 tests, 8 passed. Without the fix, all 8 fail. - `NatsJetstreamProducerIT` (new, Testcontainers): 5 tests, 5 passed. These cover a sync wait of 3000 ms and 500 ms, the async timeout message, the jnats cancel message, stream creation, and no creation when another stream takes in the subject. Without the fix, 4 fail; the overlap guard passes both ways. - Whole module `mvn verify`: 1063 unit tests and 36 ITs, all passed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
