davsclaus opened a new pull request, #24792: URL: https://github.com/apache/camel/pull/24792
## Summary `JpaMessageIdRepository` hardcodes `usePassedInEntityManager=true` in all `getTargetEntityManager()` calls, which causes it to grab the `EntityManager` from the exchange's `CamelEntityManager` header. When used downstream of a JPA consumer (which puts its own poll-scoped EM in that header), the repository then **closes** the consumer's EM in its `finally` block, causing `IllegalStateException: EntityManager is closed` during the consumer's subsequent flush/clear. ## Fix Changed `usePassedInEntityManager` from `true` to `false` in all four `getTargetEntityManager()` calls (`add`, `contains`, `remove`, `clear`). This makes the repository always create its own EM via its own `entityManagerFactory`, matching `JpaEndpoint`'s default behavior. The existing `finally` close logic is then correct — the repository only closes EMs it created itself. _Claude Code on behalf of davsclaus_ -- 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]
