spring-integration - 线接头作为异步通道?
问题描述
使用“窃听”作为二线逻辑通道是否正确?
或者我应该使用其他方法?我没有找到任何合适的东西(pubSubChannel?)
例如:
@Bean
HttpRequestHandlingMessagingGateway srvPutVers() {
return Http.inboundGateway("/srvPutVers")
.requestChannel("callLogicAndReply.input")
.requestPayloadType(SomeRq.class)
.get();
}
@Bean
IntegrationFlow callLogicAndReply() {
return f -> f
.wireTap("logicHard.input")
.transform(p -> "{\"status\": \"Ok\"}");
}
@Bean
IntegrationFlow logicHard() {
return f -> f
.log("hard logic");
}
解决方案
如果您希望它wireTap("logicHard.input")
是异步的,您需要从相应的注入开始您的logicHard
流程。或。查看工厂及其:ExecutorChannel
Executor
QueueChannel
IntegrationFlows
/**
* Populate the {@link MessageChannel} object to the
* {@link IntegrationFlowBuilder} chain using the fluent API from {@link MessageChannelSpec}.
* The {@link org.springframework.integration.dsl.IntegrationFlow} {@code inputChannel}.
* @param messageChannelSpec the MessageChannelSpec to populate {@link MessageChannel} instance.
* @return new {@link IntegrationFlowBuilder}.
* @see org.springframework.integration.dsl.MessageChannels
*/
public static IntegrationFlowBuilder from(MessageChannelSpec<?, ?> messageChannelSpec) {
看那个MessageChannels
工厂。
另一方面,如果您谈论并行逻辑,那么最好看看PublishSubscribeChannel
with an Executor
option。您的logicHard
流程逻辑可能会保留。只有您需要拥有一个全局PublishSubscribeChannel
bean 并从此通道开始该流程。在主要流程中,.wireTap("logicHard.input")
您需要使用普通channel(myPublishSubscribeChannel())
的来引用同一个 bean。
推荐阅读
- cube.js - cube.js:将原始 sql 查询发送到多维数据集服务器
- c++ - 如果我们已经在 .h 文件中添加了相同的命名空间,我们是否需要为 -inl.h 添加相同的命名空间
- javascript - 我无法在 VSCode 中运行控制台登录
- asp.net-core - 两个客户端之间的 asp.NET 核心 signalR 隧道
- c++ - 如何通过引用函数传递对象并访问公共结构中的变量
- wordpress - 在 wordpress 上构建祈祷词的表格
- c# - 按住两个按钮时,Sprite 只会向一个方向移动
- java - 在android应用程序中使用viewpager 2覆盖在底部导航和抽屉布局中的片段
- bluetooth - 为 Cycling Trainer 解码蓝牙 HCI 日志
- android - arrayListOf 显示 Int 而不是 String - Kotlin