There is an Azure Service Bus Queue with the session property enabled (Requires session = true)
The consumer is a native Azure Java "client" (com.azure:azure-messaging-servicebus)
The problem is that there is no way with this Java client to close the session manually.
As a result, when maxConcurrentSessions
reached the whole application stop receiving messages until the session lock timeout reached.
So the main question here is: How can we close a session manually using the Java client?
Might help:
In this article there is an example how to do it but is on C#. It seems that there is a "session" object used to close the session. I was not able to reproduce it in the Java client.
https://devblogs.microsoft.com/premier-developer/ordering-messages-in-azure-service-bus/
Code of the client init:
new ServiceBusClientBuilder()
.connectionString(queueConnectionString)
.sessionProcessor()
.queueName(queueName)
.maxConcurrentSessions(5)
.maxConcurrentCalls(2)
.processMessage(this::processMessage)
.processError(this::processError)
.maxAutoLockRenewDuration(Duration.ofMinutes(30))
.disableAutoComplete()
.buildProcessorClient();