Details
-
Improvement
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
2.18.3
-
None
-
None
-
Java JDK 1.8.0_121
Spring 4 (reproduced with Spring Boot 1.5.3)
RedHat RHEL 7.1 x86_64
Oracle 11G
-
Unknown
Description
Deploying 4 instances of the same app containing a camel-jpa consumer polling on the same database, I noticed that several servers can consume the same entities.
The polling is currently done as follow :
- Poll without lock on the `maxResult` first rows
- On each row :
- Apply a lock select ... for update (NOWAIT)
- Consume entity
- Release the lock (commit)
- New Transaction
- Process exchange
- End Transaction
What can happen with several instances of the consuming on the same database is :
- Server 1 polls the 10 first rows
- Server 2 polls the same 10 first rows
- Server 1 locks row 1 for update and consume it
- Server 2 locks row 1 for update as the previous lock is already released and consumes it
This demand is related to my previous post on the user forum : http://camel.465427.n5.nabble.com/JPA-consumer-component-is-not-handling-multiple-server-concurrent-polling-td5797937.html