allthingssecurity opened a new pull request, #27307:
URL: https://github.com/apache/camel/pull/27307

   # Description
   
   [CAMEL-25278](https://issues.apache.org/jira/browse/CAMEL-25278)
   
   The producers and consumers of a host and port share one CometD server, 
which is only stopped with the last of them:
   
   - `CometdConsumer` added its service (a listener of the channel) on start 
and never removed it. When the server outlived the consumer (a producer, or 
another consumer, on the same host and port), the stopped consumer kept calling 
the processor of the route: after a restart of the route each message was 
processed twice, once more per restart.
   - `CometdComponent.connect` added the configured extensions and server 
listeners to the server for every producer and consumer that connected, so with 
a producer and a consumer on the same host and port each one was called twice 
per message or session, and once more after each restart.
   
   This change: the consumer removes its service from the channel and 
disconnects its local session on stop; the component sets the security policy 
and adds the extensions and server listeners only when it creates the server.
   
   Tests:
   - `CometdConsumerRestartTest` (new, 3 tests): a producer route and a 
consumer route on the same host and port; restart of the consumer route then 
one message; a `SessionListener` and one new session; a stopped consumer route 
(control, passes without the change too).
   - Without the change 2 fail: `mock://test Received message count. Expected: 
<1> but was: <2>`, and `expected: <1> but was: <2>` for the listener.
   - With the change all camel-cometd tests pass: 26 tests, 0 failures.
   
   # 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).
   
   # 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 the affected module, including the formatter and 
import-sort plugins. 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]

Reply via email to