With Spring 5.3.29, how can I detect that a MessageDriveChannelAdapter is connected to JMS without receiving a message.
Currently, I have;
IntegrationFlows.from(
Jms
.messageDrivenChannelAdapter(connectionFactory)
.destination(myDestination)
.errorChannel(myErrorChannel)
.configureListenerContainer(c -> {
c.errorHandler(...);
c.exceptionListener(...);
})
.handle(...)
.get();
By implementing the ErrorHandler and ExceptionListener I can alert that we are not connected. I could implement "clear alert" logic in the handle(), but I want to "clear" without getting a message.
There is no event like that in Spring JMS, nor JMS spec by itself. And probably there is indeed no reason in it: when you receive a message in the
handle(), that's definitely an indicator that connection to JMS broker was OK. If connection fails, thatexceptionListener()would do that trick.You can do that "clear" logic in the
ChannelInterceptorbefore thathandle().See
intercept()DSL operator: