atiaomar1978-hub opened a new pull request, #25001: URL: https://github.com/apache/camel/pull/25001
# CAMEL-23938: Camel-managed session lock renewal for session-enabled Service Bus consumers Follow-up from CAMEL-23937. ## Problem CAMEL-23937 added Camel-managed lock renewal for **non-session** Azure Service Bus consumers using `ServiceBusReceiverAsyncClient.renewMessageLock()`. Session-enabled consumers were **explicitly excluded**, because session locks require a different API: - Session locks must be renewed via `renewSessionLock()` instead of `renewMessageLock()` - This requires a session-bound receiver (`acceptSession(sessionId)`) - The session id is only known at message-receive time, not at consumer startup As a result, session-enabled consumers in async routes still suffered from silent session-lock expiry mid-processing. ## Solution Added a `SessionLockRenewer` in `ServiceBusConsumer` that: 1. Creates session-bound async receivers on demand, keyed by session id, via `ServiceBusSessionReceiverAsyncClient.acceptSession(sessionId)` 2. Renews session locks with `renewSessionLock()` as they approach expiry 3. Reference-counts in-flight exchanges per session and closes the session receiver once the last exchange for that session completes 4. Honours `maxAutoLockRenewDuration` per exchange Also added `ServiceBusClientFactory.createServiceBusSessionReceiverAsyncClient()`. The behavior activates automatically when: no custom `processorClient`, `PEEK_LOCK` mode, `maxAutoLockRenewDuration > 0`, and session mode is enabled. ## Tests Added AssertJ test coverage in `ServiceBusConsumerTest`: - Session lock renewer created for session-enabled PEEK_LOCK, not for RECEIVE_AND_DELETE - Exchange tracking and cleanup (session receiver closed after completion) - `renewSessionLock()` invoked when the lock is expiring - Session receiver reused across messages of the same session - Session receiver kept open until the last exchange for the session completes - Stop/start lifecycle recreates and cleans up the session renewer `mvn test -pl components/camel-azure/camel-azure-servicebus` passes. ## Docs Updated the 4.22 upgrade guide entry to cover session lock renewal. --- _Claude Opus 4.8 on behalf of atiaomar1978-hub_ -- 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]
