所以我正在开发一个拥有数百个流的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"/>
请提出任何建议,提前谢谢。
答案 0 :(得分: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。验证后设置到下一个元素的路径,并从验证流程中的最后一个元素中删除输出通道。