java - Spring Integration 并行处理,无需聚合

标签 java spring message spring-integration duplicate-data

我找不到足够/清晰的文档。

我收到来自链处理的消息。一旦 channel 收到消息,我想有条件地复制该消息。

简单流程:

<int-http:inbound-gateway request-channel="httpRequestChannel" reply-channel="httpResponseChannel" supported-methods="POST" 
    path="/doSomething" request-payload-type="com.xxx.Request" >
</int-http:inbound-gateway>

<int:chain id="msgChain" input-channel="httpRequestChannel" output-channel="processChannel">
    <int:claim-check-in message-store="messageStore"/>
    //do something
</int:chain>

<int:chain id="msgChain2" input-channel="processChannel" output-channel="parallelChannel">
    <int:claim-check-in message-store="messageStore"/>
    //do something
</int:chain>

<int:chain id="parallelChainId" input-channel="parallelChannel" output-channel="httpResponseChannel">
    <int:claim-check-in message-store="messageStore"/>
    if(payload infrom3rdparty property set i.e. payload.infrom3rdparty == true){
           send this message to //3party Channel
    }
    //do something
</int:chain>

我无法应用过滤器,因为丢弃消息会转到不同的 channel ,例如if else。但我只需要 if 将消息复制到另一个 channel

最佳答案

也许您可以尝试使用具有 2 个订阅者的发布-订阅 channel : - 遵循的标准流程 - 复制流程

在复制流程中,您可以使用过滤器来选择是否发送消息。可能是这样的:

<int:publish-subscribe-channel id="parallelChannel"/>

<int:chain id="standardFlowChain" input-channel="parallelChannel" output-channel="httpResponseChannel">
    <int:claim-check-in message-store="messageStore"/>
    //follow the standard flow
</int:chain>
<int:chain id="thirdPartyFlowChain" input-channel="parallelChannel" output-channel="thirdPartyOutputChannel">
    <int:claim-check-in message-store="messageStore"/>
    <int:filter expression="payload.infrom3rdparty == true"/>
</int:chain>

关于java - Spring Integration 并行处理,无需聚合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31224357/

相关文章:

java - Kafka 消息 - Java 中的生产者和消费者客户端

java - 如何切换到单击按钮后打开的新浏览器窗口?

java - Spring Data JPA 中的 CrudRepository 和 JpaRepository 接口(interface)有什么区别?

java - JSF 验证消息

macos - AppleScript 创建 'link' 到特定的 Messages.app 对话?

java - 连接到远程数据库

java - 如何反序列化这个动态值 JSON?

java - 如何将数据从jsp表单传递到 Controller

java - Spring boot mongoDB聚合piple-line没有找到类型的属性

wcf - 为 WCF webhttp 设置最大消息和缓冲区大小