allthingssecurity opened a new pull request, #28203: URL: https://github.com/apache/camel/pull/28203
# Description [CAMEL-25813](https://issues.apache.org/jira/browse/CAMEL-25813) The `pulsar` producer always passed `initialSequenceId` to the Pulsar client builder, and the option defaults to -1. The Pulsar client continues after the last sequence id the broker has for the producer name only when no initial sequence id is set (`ProducerImpl.connectionOpened`: `msgIdGenerator == 0 && conf.getInitialSequenceId() == null`). With -1 set, every start of the producer began again at sequence id 0. With a `producerName` and deduplication enabled on the broker, the broker then dropped the messages sent after each restart (application restart, route stop/start, reload) as duplicates, until the sequence ids passed the ones of the previous run. The send still succeeded, so the exchange completed and nothing was logged. Change (in `PulsarProducer.createProducer`): the initial sequence id is passed only when it is 0 or more. The default -1 leaves it to the client. No option or default changes. The option description (the explicit `@UriParam` description, which is what the options table shows) now says what the default -1 does; the component JSON, its catalog copy and the endpoint and component DSL are regenerated. What users can notice: with deduplication and a `producerName`, the messages after a restart are no longer dropped. A short section in `pulsar-component.adoc` (and its catalog copy), the description and javadoc of the option, and a `camel-pulsar` note in the 4.24 upgrade guide. Tests: - New `PulsarProducerInitialSequenceIdTest`. A mocked `PulsarClient` returns the real `ProducerBuilderImpl` of the Pulsar client with only `create()` stubbed, so the test reads the configuration the producer is created with. Without the change, `testTheBrokerSequenceIdIsUsedByDefault` and `testTheBrokerSequenceIdIsUsedAfterARestart` fail with `expected: <null> but was: <-1>`. With the change they pass. `testAConfiguredInitialSequenceIdIsUsed` (`initialSequenceId=41`) passes before and after. - With the change the camel-pulsar unit tests pass: 33 run, 0 failures, 0 errors, 0 skipped. How it was found: variant analysis of CAMEL-25789 (camel-aws2-s3 stream upload). That issue's pattern is an id built from a counter that starts again at every start, so a restart collides with what the previous run wrote. I then read how the Pulsar client sets up its sequence ids and wrote the test above. What was not run: the ITs (they need Docker); a test against a Pulsar broker with deduplication enabled; the full root build. # Target - [x] I checked that the commit is targeting the correct branch (Camel 4 uses the `main` branch) # Tracking - [x] If this is a large change, bug fix, or code improvement, I checked there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for the change (usually before you start working on it): [CAMEL-25813](https://issues.apache.org/jira/browse/CAMEL-25813). # Apache Camel coding standards and style - [x] I checked that each commit in the pull request has a meaningful subject line and body. - [ ] I have run `mvn clean install -DskipTests` locally from root folder and I have committed all auto-generated changes. (I built and tested camel-pulsar, including the formatter and import-sort plugins. No option metadata changed; the catalog copy of the edited doc page is updated by hand. I did not run the full root build.) # AI-assisted contributions - [x] If this PR includes AI-generated code, commits have proper co-authorship attribution (e.g., `Co-authored-by` trailers) and the PR description identifies the AI tool used. This PR was prepared with Claude Code (Claude Opus 5.5). The commit carries a `Co-Authored-By` trailer. _Claude Code on behalf of allthingssecurity_ 🤖 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]
