【问题标题】:Spring Integration FlowsSpring 集成流程
【发布时间】:2016-03-02 17:10:16
【问题描述】:

所以我正在开发一个包含数百个流程的 spring 集成应用程序。所有这些流程基本上代表了应用程序中的一个服务,例如

Report Generation
Customer Search
Get Customer Transactions
Customer Activity Stream
etc.

我想验证发送到这些流的请求(基本上检查参数规范是否满足),所以我单独创建了另一个流来验证请求,以便发送到上述服务的任何请求都将首先通过验证流。 现在我想知道如何将其纳入服务流程。

详情见下文。

验证流程--->

    <int:channel id="svcExeGovernorEntryLoggerChannel"/>

    <int:channel id="svcExeGovernorEntryRespChannel" >
        <int:interceptors>
            <int:wire-tap channel="svcExeGovernorEntryLoggerChannel"/>
        </int:interceptors>
    </int:channel>

    <int:transformer id="serviceExecutionGovernorEntry" ref="serviceExecutionGovernor" method="serviceExecutionEntry" input-channel="svcExeGovernorEntryReqChannel" output-channel="svcExeGovernorEntryRespChannel"/> 

    <int:logging-channel-adapter id="svcExeGovernorEntryLogger" channel="svcExeGovernorEntryLoggerChannel"  logger-name="svcExeGovernor-entry-logger" />

</beans>

我尝试使用如下的网桥,但这些都不起作用,它将输出发送到另一个服务。

<int:channel id="customerCrawlReqChannel">
        <int:interceptors>
            <int:wire-tap channel="customerCrawlLoggerChannel"/>
        </int:interceptors>
    </int:channel>
    <int:channel id="customerCrawlRespChannel">
        <int:interceptors>
            <int:wire-tap channel="customerCrawlLoggerChannel"/>
        </int:interceptors>
    </int:channel>
    <int:channel id="customerCrawlLoggerChannel"/>
    <int:channel id="customerCrawlResultChannel">
        <int:interceptors>
            <int:wire-tap channel="customerCrawlLoggerChannel"/>
        </int:interceptors>
    </int:channel>
    <int:channel id="customerCrawlJsonChannel"/>

    <http:inbound-gateway id="customerCrawlInboundGateway"
                          supported-methods="POST"
                          mapped-request-headers="User-Agent,Content-Type"
                          request-payload-type="java.lang.String"
                          path="/service/customercrawl"
                          reply-timeout="50000"
                          request-channel="customerCrawlReqChannel"
                          reply-channel="customerCrawlRespChannel">        
    </http:inbound-gateway>


    <int:bridge input-channel="customerCrawlReqChannel" output-channel="svcExeGovernorEntryReqChannel"/>


    <int:transformer id="customerCrawlPrvder" ref="crawlCustomerProviderService" method="crawlCustomer" input-channel="svcExeGovernorEntryRespChannel" output-channel="customerCrawlResultChannel"/>        


    <int:header-enricher input-channel="customerCrawlResultChannel"        output-channel="customerCrawlRespChannel">
        <int:header name="Content-Type" expression="'application/json'" />
    </int:header-enricher>       
    <int:logging-channel-adapter   
    id="customerCrawlLogger"channel="customerCrawlLoggerChannel"  logger-
    name="customerCrawl-logger"/>

请对此提出任何建议,在此先感谢。

【问题讨论】:

    标签: spring spring-integration channel


    【解决方案1】:

    如果svcExeGovernorEntryRespChannel 有多个订阅者,则这些响应将循环分发给这些消费者;框架中没有任何内容可以告诉您返回哪个订阅流。

    如果您想将相同的验证流程添加到同一上下文中的多个流程,请使用中间流程网关...

    <int:service-activator 
                input-channel="customerCrawlReqChannel" 
                output-channel="customerCrawlReqAfterValidationChannel"
                ref="validationGW" />
    
    <int:gateway id="validationGW"
                default-request-channel="svcExeGovernorEntryLoggerChannel"
                default-reply-channel="svcExeGovernorEntryRespChannel" />
    

    这就像java中的方法调用,输入消息作为参数,输出消息作为结果。

    或者,您可以使用routing slip。设置验证后到下一个元素的路由,并从验证流中的最后一个元素中移除输出通道。

    【讨论】:

    • 嗨,加里,谢谢,看起来这很有效,到目前为止,我已经为 3 个服务流完成了它,并且很好。再次感谢
    • 酷;此处习惯将答案标记为“已接受”(选票下方的绿色复选标记/勾号)。它将在搜索类似问题时帮助其他用户。
    猜你喜欢
    • 2021-07-09
    • 1970-01-01
    • 2015-01-16
    • 2023-04-07
    • 2019-04-30
    • 2016-05-21
    • 2020-04-20
    • 2014-06-11
    • 1970-01-01
    相关资源
    最近更新 更多