2013-11-21 85 views
2

我是新来的骡子,这就是我想要做的。 1)呼叫出站休息服务A 2)循环播放结果并呼叫休息服务B 3)汇总来自服务B的结果并返回有效载荷。 下面是我想出来的,但是这个流程返回的是服务A的结果。如何忽略A的结果并返回B的聚合结果?我在循环内部添加了记录器,可以看到B的响应,但不知道如何将结果返回给用户?我需要自定义聚合器吗?Mule - 如何汇总来自foreach的结果并返回结果?

<flow name="test1Flow1" doc:name="test1Flow1"> 

    <http:inbound-endpoint exchange-pattern="request-response" doc:name="HTTP1" address="http://localhost:8082"/> 
     <copy-properties propertyName="*" doc:name="Property"/> 
     <http:outbound-endpoint doc:name="HTTP2" followRedirects="true" address="http://abcd/catalog/#[message.inboundProperties['http.relative.path']]?#[message.inboundProperties['http.query.string']]" contentType="text/xml"/> 

    <foreach doc:name="For Each" collection="#[xpath('//mc:assets/mc:asset')]"> 

    <http:outbound-endpoint doc:name="HTTP3" address="http://abcd#[xpath:@href]" contentType="text/xml" method="GET"/> 
    <collection-aggregator failOnTimeout="true" doc:name="Collection Aggregator"/>   
    </foreach> 

</flow> 

感谢任何帮助!

回答

0

Mule中的foreach像循环一样工作,并且一次起到分离器和聚合器的作用。

我相信您一定能够实现你的使用情况有以下:

在HTTP
    1. 了HTTP与
    2. 分流
    3. 了HTTP乙
    4. 聚合

    看看here的例子分离器和聚合器。

    问候