Spring 集成流程
Spring Integration Flows
所以我正在开发一个 spring 集成应用程序,其中有数百个 flows.All 这些流基本上代表应用程序中的一项服务,例如
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"/>
请对此提出任何建议,在此先感谢。
如果 svcExeGovernorEntryRespChannel
有多个订阅者,那么这些响应将循环分配给这些消费者;框架中没有任何内容可以判断哪个订阅者流向 return。
如果要将相同的验证流添加到同一上下文中的多个流,请使用中间流网关...
<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。设置验证后到下一个元素的路由,并从验证流中的最后一个元素中删除输出通道。
所以我正在开发一个 spring 集成应用程序,其中有数百个 flows.All 这些流基本上代表应用程序中的一项服务,例如
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"/>
请对此提出任何建议,在此先感谢。
如果 svcExeGovernorEntryRespChannel
有多个订阅者,那么这些响应将循环分配给这些消费者;框架中没有任何内容可以判断哪个订阅者流向 return。
如果要将相同的验证流添加到同一上下文中的多个流,请使用中间流网关...
<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。设置验证后到下一个元素的路由,并从验证流中的最后一个元素中删除输出通道。