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

   Thanks for the reviews. All three points are addressed in b6cb99422a82.
   
   **Negative `lockTimeout`** (gnodet-bot): confirmed, and the URI path has the 
same problem. `TimeUtils.toDuration` converts `-1`, `-1s` and `-PT1S` to a 
negative duration, so `lockTimeout=-1s` also gave no hint and waited for ever. 
camel-jpa checks its consumer options when it creates or starts the consumer, 
not in setters (`JpaEndpoint.validate`, `JpaPollingConsumer.doInit`). Core does 
the same for the backoff options in `ScheduledPollConsumer.doInit`. So 
`JpaConsumer.doInit` now throws `IllegalArgumentException("lockTimeout must be 
>= 0, was: ...")` and the route does not start. This covers the URI, the 
endpoint DSL, `JpaEndpoint.setLockTimeout` and `JpaConsumer.setLockTimeout`. 
New tests: `negativeLockTimeoutInTheUriIsRejected` (`lockTimeout=-1s`) and 
`negativeLockTimeoutOfTheConsumerIsRejected`. Both fail without the check.
   
   **Hint type** (gnodet-bot): `NOWAIT` now uses `0` (an Integer), the same 
type as the `lockTimeout` hint. Both providers already accepted either type, so 
nothing changes at runtime:
   - OpenJPA 4.1.1 converts the hint to the `int` argument of 
`FetchConfigurationImpl.setLockTimeout` 
(`Filters.convertToMatchMethodArgument`, which allows Long to Integer).
   - Hibernate 7.4 reads any `Number` with `intValue()` 
(`LockOptionsHelper.applyTimeout`).
   
   I also called the real `EntityManager.lock` with both hints under each 
provider on H2. `skipLockedEntityDoesNotWaitWhateverTheLockTimeout` now expects 
the Integer and fails with the old `0L`.
   
   **Entities routed again on PostgreSQL** (davsclaus): confirmed by a new IT, 
`entitiesAheadOfALockedEntityAreRoutedAgainByEachPoll`. Another transaction 
locks entity 2. Each of three polls routes entity 1, and then the lock on 
entity 2 times out. The poll then fails to commit the delete of entity 1 
(`current transaction is aborted`) and is rolled back, so entity 1 stays in the 
table. Once the lock is released, the next poll consumes all three. The 
PostgreSQL bullet in "Locking the consumed entities" now says this repeats on 
every poll for as long as the other transaction holds the lock, and that the 
route must be idempotent or the transaction holding the lock must be ended. The 
`lockTimeout` option description has a short pointer, regenerated in 
`jpa.json`, the catalog and the endpoint DSL.
   
   camel-jpa tests and `JpaConsumerLockTimeoutIT` pass with the default 
(OpenJPA) profile and with `-Dhibernate`.
   
   _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