Croway commented on PR #30209:
URL: https://github.com/apache/camel/pull/30209#issuecomment-6928138639

   Thanks for the reviews. Addressed in 1d91299b3eca:
   
   **@davsclaus**
   
   1. **Skipped only when deleted**: done. The doc now says that an entity 
another consumer has deleted since the poll listed it (`consumeDelete=true`, 
the default) is skipped, and that one it only updated (`consumeDelete=false`) 
is not: its row is still there, and the select returns it once the other 
transaction has ended. The OpenJPA sentence and the upgrade-guide entry say 
"deleted" too, and the tests are renamed 
`entityDeletedByAnotherConsumerIsSkipped`.
   2. **`PESSIMISTIC_READ`**: done. The doc says that consumers sharing a table 
need a lock mode that locks the row exclusively, `PESSIMISTIC_WRITE` (the 
default) or `PESSIMISTIC_FORCE_INCREMENT`, and that `PESSIMISTIC_READ` takes a 
shared lock (`FOR SHARE` on PostgreSQL, `PostgreSQLDialect.getReadLockString` 
in 7.4.15) that another consumer gets too, so two consumers can route the same 
entity.
   3. **Versioned entity test**: added 
`forceIncrementSkipsLockedEntityAndIncrementsVersion` (H2), with a new 
XML-mapped `SkipLockedVersionedItem` (`<version>`), 
`PESSIMISTIC_FORCE_INCREMENT` and `consumeDelete=false`. Another connection 
holds entity 2: 1 and 3 are routed and go to version 1, 2 is skipped and stays 
at 0. With the `lock()` after the SKIP LOCKED select removed, it fails with 
`expected: <{3=1, 2=0, 1=1}> but was: <{1=0, 2=0, 3=0}>`.
   4. **Caching a failed check**: done. Only an answer is cached now. When 
`getDelegate()` throws (`IllegalStateException`, `PersistenceException`) or 
returns null, that lock uses NOWAIT and the next one checks again; "no 
Hibernate" (`ClassNotFoundException`, `LinkageError`, not an 
`org.hibernate.Session`) is still kept. Test 
`providerCheckThatFailsIsCheckedAgain`: `getDelegate()` throws once, then 
returns the Hibernate session; the first lock is NOWAIT, the next two use SKIP 
LOCKED, and `getDelegate()` is called twice. With the previous caching it fails 
with `Wanted but not invoked: entityManager.getCriteriaBuilder()`.
   
   **gnodet-bot**: `<p/>` left as is, like the rest of `JpaConsumer`.
   
   The camel-jpa unit tests and the PostgreSQL ITs 
(`JpaConsumerSkipLockedEntityIT`, `JpaConsumerLockTimeoutIT`) pass in the 
OpenJPA (default) and Hibernate (`-Dhibernate`) profiles.
   
   _Claude Code on behalf of Croway_
   


-- 
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