我想要实现以下场景:FUSE中的CXF路由接收SOAP请求,从请求中提取多个ID,使用ID创建不同的SOAP消息,将其发送到服务A.这……
好的,实际工作的版本是:
路由配置: 浓缩呼叫必须是同一个驼峰环境中的分离路线:
<route id="direct:enrichroute"> <from uri="direct:enrichroute"/> <bean ref="processorBean"/> <to uri="cxf:bean:intermediateEndpoint"/> </route>
在实际路由中,我们在from和to之间插入富集并配置聚合策略bean:
<route id="someRoute"> <from uri="cxf:bean:incomingEndpoint"/> <enrich uri="direct:enrichroute" strategyRef="aggregationStrategyBean"/> <to uri="cxf:bean:finalEndpoint"/> </route>
其中cxf:bean:incomingEndpoint是ESB中的入口点,finalEndpoint是最终目标。 使用此配置,富集路由中的处理器获取请求主体,以便它可以创建富集请求主体,将其发送到富集端点。此外,在实际路由中,聚合处理器知道原始请求主体和丰富响应主体,因此它可以插入必要的数据。
处理器类:
public class ProcessorBean implements Processor { @Override public void process(Exchange exchange) throws Exception { // original request body can be fetched from exchange // we can override the request body before sending it exchange.getIn().setBody(newRq); } }
聚合策略类:
public class AggregationStrategyBean implements AggregationStrategy { @Override public Exchange aggregate(Exchange originalExchange, Exchange intermediateExchange) { } }