使用 Spring 5.3.29,如何在不接收消息的情况下检测到
MessageDriveChannelAdapter
is 连接到 JMS。
目前,我有;
IntegrationFlows.from(
Jms
.messageDrivenChannelAdapter(connectionFactory)
.destination(myDestination)
.errorChannel(myErrorChannel)
.configureListenerContainer(c -> {
c.errorHandler(...);
c.exceptionListener(...);
})
.handle(...)
.get();
通过实施
ErrorHandler
和 ExceptionListener
我可以提醒我们没有连接。我可以在 handle()
中实现“清除警报”逻辑,但我想在没有收到消息的情况下“清除”。
Spring JMS 中没有类似的事件,JMS 规范本身也没有这样的事件。也许确实没有任何原因:当您在
handle()
中收到一条消息时,这绝对表明与 JMS 代理的连接正常。如果连接失败,exceptionListener()
就能做到这一点。
您可以在
ChannelInterceptor
之前的handle()
中执行“清晰”的逻辑。
参见
intercept()
DSL 运营商:
/**
* Add one or more {@link ChannelInterceptor} implementations
* to the current {@link #currentMessageChannel}, in the given order, after any interceptors already registered.
* @param interceptorArray one or more {@link ChannelInterceptor}s.
* @return the current {@link BaseIntegrationFlowDefinition}.
* @throws IllegalArgumentException if one or more null arguments are provided
* @since 5.3
*/
public B intercept(ChannelInterceptor... interceptorArray) {