oscerd opened a new pull request, #27870: URL: https://github.com/apache/camel/pull/27870
## Motivation The jgroups-raft consumer (`enableRoleChangeEvents=true`) uses `CamelRoleChangeListener.roleChanged`, which only mapped `Leader` and `Follower` and threw `JGroupsRaftException` for anything else. jgroups-raft 1.1.x (Camel uses 1.1.4.Final) has a third role, `Learner` — a non-voting follower — and `RAFT._removeServer()` moves a removed node straight from `Leader` to `Learner`, without passing through `Follower`. `RAFT` catches the exception the listener throws, so nothing crashes, but the consumer route gets **no event** when its node steps down from leader. A route that starts work on `LEADER` and stops it on `FOLLOWER` keeps acting as leader after the node was removed. Found as the consumer-side companion to CAMEL-25488 (#27613), which fixed the same gap in the cluster-side `JGroupsRaftClusterView` / `ClusterRoleChangeListener`. ## Change - Map `Learner` to a `FOLLOWER` event (a learner is a non-voting follower), so a route that steps down on `FOLLOWER` also steps down when this node becomes a learner. This mirrors #27613's cluster-side handling (`Follower`/`Learner` fall-through) and fixes the described step-down bug. - Make the `default` branch log at `WARN` and ignore the role instead of throwing — guards against future jgroups-raft roles without silently dropping events (RAFT swallows a thrown exception). - Extract the role→event mapping into a package-private `toEventType(Role)` so it can be unit-tested directly (the existing consumer test needs a live 3-node cluster and can't force a `Learner`). Computing the event type before creating the exchange also avoids leaking a pooled exchange on the ignored-role path. I chose the `FOLLOWER` mapping (the alternative the issue offered) over a new `JGroupsRaftEventType.LEARNER` value, for consistency with #27613 and because it directly fixes the "keeps acting as leader" case for routes that handle `FOLLOWER`. Happy to switch to a distinct `LEARNER` event type if you'd prefer the consumer to expose the distinction. ## Testing New `CamelRoleChangeListenerTest` unit-tests `toEventType`: `Leader`→`LEADER`, `Follower`→`FOLLOWER`, `Learner`→`FOLLOWER`. `camel-jgroups-raft` module build is green. _Claude Code on behalf of oscerd_ 🤖 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]
