gnodet commented on PR #31133: URL: https://github.com/apache/camel/pull/31133#issuecomment-7289576145
Thank you for the detailed architectural review, @davsclaus. The core concern is correct. Calling `acceptSession(sid).block()` on a second `ServiceBusSessionReceiverAsyncClient` while the session processor already holds the session lock will fail with `AmqpException` — the SDK's own javadoc for `acceptSession()` documents this: *"If the session is already locked by another client, an AmqpException is thrown."* The current implementation catches that exception and logs a warning, which means session lock renewal silently never runs. The PR does not fix the original bug. The two concurrency fixes (volatile field, `computeIfPresent` in the error handler) from the earlier review iterations remain correct regardless of the approach taken, but the core mechanism is broken. **On the v2 stack renewing the session lock automatically:** The v2 session processor stack calls `beginLockRenew()` from the moment the session is acquired, with `maxAutoLockRenewDuration` as the ceiling. What davsclaus identifies as the actual problem — `sessionIdleTimeout` firing when the route takes longer than the idle timeout — is a different root cause than what this PR addresses. If the v2 stack already renews the session lock for `maxAutoLockRenewDuration` from session acquisition time, then the issue is *when* that countdown starts and whether `sessionIdleTimeout` cuts it short, not the lack of a Camel-side renewer. **Proposed path forward (for gnodet to decide):** 1. **If the v2 stack already handles lock renewal** (and the real problem is `sessionIdleTimeout`): drop the `SessionLockRenewer` entirely, expose `sessionIdleTimeout` as a configurable option in `ServiceBusConfiguration`, and document the interaction with async routes. This would be a smaller, safer PR. 2. **If the fix does need to be Camel-side**: the `renewSessionLock()` call must go through the receiver that the processor already holds for that session — not a second one. The `ServiceBusReceivedMessageContext` passed to `processMessage` does not expose `renewSessionLock()` directly, but the session receiver bound to the processor does. This would require a different access pattern (e.g., storing the receiver from the context or using the `ServiceBusProcessorAsyncClient` once it ships). 3. **Document and defer**: if neither approach is straightforward in the current SDK, document the limitation for `sessionEnabled=true` with async routes as davsclaus suggests. Closing the PR would be premature — the problem is real. But the approach needs to change before this can go in. _Hermès on behalf of @gnodet._ -- 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]
