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

   # Description
   
   [CAMEL-25811](https://issues.apache.org/jira/browse/CAMEL-25811)
   
   The `keycloak` consumer asks Keycloak for `first`/`maxResults` events in 
each poll (default 100) and makes the newest one its checkpoint; later polls 
skip every event older than the checkpoint. Keycloak returns the events most 
recent first. So when more than `maxResults` user or admin events happened 
between two polls, the poll routed the newest `maxResults`, and the older new 
events were never returned again: lost, and nothing was logged. This happens in 
a busy realm, with a smaller `maxResults` as in the documentation examples 
(50), and at the first poll after Keycloak was unreachable for a while.
   
   Change (in `KeycloakConsumer`): once a checkpoint is set, a poll also reads 
the following pages (`first + maxResults`, ...) until a page reaches an event 
older than the checkpoint or is shorter than `maxResults`. If new events arrive 
while the pages are read, a page repeats events of the previous one; the 
existing fingerprints skip them. The fingerprint cache is now limited after the 
poll, when only the fingerprints at the checkpoint are left, instead of while 
the events of a poll are read (a poll of more than 1000 events would otherwise 
route some events twice). The first poll is unchanged.
   
   What users can notice: a poll can route more than `maxResults` events. A 
short note in `keycloak-consumer.adoc` (and its catalog copy), the `maxResults` 
row of the consumer options table there and the option description, which said 
"per poll" (the component JSON, its catalog copy and the endpoint and component 
DSL are regenerated), and a `camel-keycloak` note in the 4.24 upgrade guide.
   
   Tests:
   - New `KeycloakConsumerMoreThanMaxResultsTest` (a mocked `RealmResource` 
that honours `first` and `max` and returns the newest events first, 
`maxResults=2`). Without the change: `routesTheEventsBeyondMaxResults` and 
`routesTheAdminEventsBeyondMaxResults` fail with `Received message count. 
Expected: <4> but was: <3>`, `newEventsArrivingWhilePagingAreRoutedOnce` with 
`Expected: <7> but was: <4>`. With the change all three pass.
   - With the change the camel-keycloak unit tests pass: 144 run, 0 failures, 0 
errors, 0 skipped. The `KeycloakConsumerLatestEventsTest` of CAMEL-25525 is 
unchanged and passes.
   
   How it was found: variant analysis of CAMEL-25806 (camel-jira newIssues) and 
CAMEL-25807 (camel-github2 commits): a polling consumer that fetches the newest 
M items and moves its cursor to the newest one it saw. The test above 
reproduces it on the real consumer.
   
   What was not run: the ITs (they need Docker and a Keycloak container); a 
test against a Keycloak server; 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-25811](https://issues.apache.org/jira/browse/CAMEL-25811).
   
   # 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-keycloak, including the formatter and 
import-sort plugins. No option 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]

Reply via email to