spring-integration - Spring Integration DSL:将一些消息发送到 Flow inputChannel 的简单方法
问题描述
如果我想生成一些示例数据来测试 Spring Integration DSL 功能,那么到目前为止我想出的一种方法是这样的:
@Bean
public IntegrationFlow myFlow() {
return IntegrationFlows
.from(Http.inboundChannelAdapter("numbers").get())
.scatterGather(s -> s
.applySequence(true)
.recipientFlow(f -> f.handle((a, b) -> Arrays.asList(1,2,3,4,5,6,7,8,9,10)))
)
.split() // unpack the wrapped list
.split() // unpack the elements of the list
.log()
.get();
}
是否有另一种/更好的方法来做同样的事情?对于如此基本的东西,使用 Scatter-Gather EIP 似乎有点过头了……
解决方案
您确实可以将流程中的特定内容注入MessageChannel
到某个测试组件中,以将消息直接发送到该通道,以便从流程中的预期端点进行处理。目前尚不清楚 scatter-gather 在您的流程中的作用以及您在标题中谈论的频道在哪里,但另一种方法是使用@MessagingGateway
界面。
在文档中查看更多信息:
https://docs.spring.io/spring-integration/docs/current/reference/html/dsl.html#java-dsl-channels
推荐阅读
- java - SDK 未注册(来自非视图构造函数,而不是 onCreate()) - 没有错误
- r - optmi方法梯度函数如何使用?
- reactjs - 当用户位于某个组件时,如何将我的按钮或图标颜色设置为不同?
- python - 为什么 python 在使用 . 导入时给出“ModuleNotFoundError: No module named '__main__.xxx'; '__main__' is not a package”?
- c++ - 为什么要在 C++ 中预定义模板参数类型?
- c - 打印到标准输出返回 gibbersih
- javascript - 为什么 style.display = "none"; 不适用于响应式导航栏
- java - (Java NIO)我应该在通道之间复制时检查字节读取和缓冲区位置吗?
- wordpress - WordPress 全新安装未将默认插件和主题更新到最新版本
- python - 正则表达式 - 如何捕获之前没有不同模式的模式?