将 adviceChain 添加到 StandardIntegrationFlow 以在消息处理程序上设置 CountDownLatch
Add adviceChain to StandardIntegrationFlow to set a CountDownLatch on a message handler
我正在尝试通过 adviceChain
和 BeanFactoryPostProcessor
将 CountDownLatch
添加到 Spring 集成中的 org.springframework.integration.dsl.StandardIntegrationFlow
。这样做的原因是为了监视此集成流中的消息处理程序是否已被调用并已完成其工作。
这里有一个不使用 Spring 集成的 Java DSL 的解决方案:spring-integration unit test outbound-channel adapter. But sadly it´s not working for me because of the Java DSL and the StandardIntegrationFlow
. Gary Russels solution looks like this: https://gist.github.com/garyrussell/5481779。我尝试这样做的例外是:
Caused by: org.springframework.beans.NotWritablePropertyException:
Invalid property 'adviceChain' of bean class [org.springframework.integration.dsl.StandardIntegrationFlow]:
Bean property 'adviceChain' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
集成流程如下所示:
@Bean
public IntegrationFlow myFlow() {
return IntegrationFlows.from(myChannel())
.handle(message -> manager.handleMessage(message))
.get();
}
我需要将 CountDownLatch
添加到 .handle()
部分,这样我就可以询问闩锁处理程序是否已完成其工作。
有什么实现方法吗?
IntegrationFlow
基本上对集成没有任何作用。它是真正 Spring 集成端点和它们之间的消息通道的逻辑容器。所以,如果你说的忠告完全是针对.handle()
,什么是真正正确的,你应该考虑这样做:
.handle(message -> manager.handleMessage(message), e -> e.advice(...))
advice()
大约是:
/**
* Configure a list of {@link Advice} objects to be applied, in nested order, to the
* endpoint's handler. The advice objects are applied only to the handler.
* @param advice the advice chain.
* @return the endpoint spec.
*/
public S advice(Advice... advice) {
我正在尝试通过 adviceChain
和 BeanFactoryPostProcessor
将 CountDownLatch
添加到 Spring 集成中的 org.springframework.integration.dsl.StandardIntegrationFlow
。这样做的原因是为了监视此集成流中的消息处理程序是否已被调用并已完成其工作。
这里有一个不使用 Spring 集成的 Java DSL 的解决方案:spring-integration unit test outbound-channel adapter. But sadly it´s not working for me because of the Java DSL and the StandardIntegrationFlow
. Gary Russels solution looks like this: https://gist.github.com/garyrussell/5481779。我尝试这样做的例外是:
Caused by: org.springframework.beans.NotWritablePropertyException:
Invalid property 'adviceChain' of bean class [org.springframework.integration.dsl.StandardIntegrationFlow]:
Bean property 'adviceChain' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
集成流程如下所示:
@Bean
public IntegrationFlow myFlow() {
return IntegrationFlows.from(myChannel())
.handle(message -> manager.handleMessage(message))
.get();
}
我需要将 CountDownLatch
添加到 .handle()
部分,这样我就可以询问闩锁处理程序是否已完成其工作。
有什么实现方法吗?
IntegrationFlow
基本上对集成没有任何作用。它是真正 Spring 集成端点和它们之间的消息通道的逻辑容器。所以,如果你说的忠告完全是针对.handle()
,什么是真正正确的,你应该考虑这样做:
.handle(message -> manager.handleMessage(message), e -> e.advice(...))
advice()
大约是:
/**
* Configure a list of {@link Advice} objects to be applied, in nested order, to the
* endpoint's handler. The advice objects are applied only to the handler.
* @param advice the advice chain.
* @return the endpoint spec.
*/
public S advice(Advice... advice) {