java - Spring 集成事件监听器入站适配器
问题描述
我有一个问题,我想在使用 dsl 的 spring 集成中实现一个输入适配器,作为事件侦听器并将消息从该事件侦听器重定向到通道。
所需的代码:
@Bean
public IntegrationFlow listenerFlow() {
return IntegrationFlows.from(InputAdapterListener.listen())
.channel("ChannelXYZ")
.get();
}
有人可以向我解释 InputAdatperListener 类的实现是什么,以支持这样的行为,或者在哪里寻找一些例子?
解决方案
ApplicationEventListeningMessageProducer
在该配置中有一个spring-integration-event
供您使用from()
:
private ApplicationListener<?> applicationListener() {
ApplicationEventListeningMessageProducer producer = new ApplicationEventListeningMessageProducer();
producer.setEventTypes(TestApplicationEvent1.class);
producer.setOutputChannel(resultsChannel());
return producer;
}
...
IntegrationFlows.from(applicationListener())
这个会自动注册为一个bean。
推荐阅读
- excel - 如何使用公式获得excel中的总正确百分比
- graphql - 一个简单的查询,但 Graphene-Django 正在返回空值
- c# - Visual Studio C#,安装应用程序后找不到 DLL
- c# - C#,.NET,在将请求转换为字符串的函数中检查 null
- python - python:pandas .describe - 如何将结果放入变量中?
- c# - 将当前用户的密码与模型属性进行比较?
- python - 遍历字典的值列表并从中删除
- javascript - 将类状态传递给功能组件(打字稿)
- python - 有什么方法可以阻止python程序崩溃?
- java - Junit 在 Java 中的配置类测试期间无法检测到 @Autowired Bean