我已经构建了一个API,该API使用克隆中介器将消息发送到多个端点。我还使用了聚合调解员来收集端点返回到一条消息的消息,然后将其发送回客户端。以下是具有骨料调解人的外序:
<outSequence>
<aggregate id="GetOpenTasksReq">
<completeCondition>
<messageCount max="-1" min="-1"/>
</completeCondition>
<onComplete expression="//jsonObject" xmlns:m0="http://ws.wso2.org/dataservice">
<log level="custom" separator=",">
<property name="MessageFlow" value="======================= Sending Back the Aggregated Responses. ==============="/>
</log>
<log level="full" separator=","/>
<enrich>
<source clone="true" xpath="//tasks"/>
<target action="child" type="body"/>
</enrich>
<property name="messageType" value="application/json" scope="axis2"/>
<send/>
</onComplete>
</aggregate>
<send/>
</outSequence>
它应该返回
{
"tasks": [
{
"id": 10,
"desc": "New Assignment Item",
"due": "2019-02-18T06:23:41+07:00",
"link": "https://[host]:[port]/viewtask?id=10"
},
{
"id": 1,
"desc": "New Assignment Item",
"due": "2019-02-18T06:23:41+07:00",
"link": "https://[host]:[port]/viewtask?id=1"
},
{
"id": 33,
"desc": "New Assignment Item",
"due": "2019-02-18T06:23:41+07:00",
"link": "https://[host]:[port]/viewtask?id=33"
}
]
}
,但我得到了:
{
"tasks": [
{
"id": 10,
"desc": "New Assignment Item",
"due": "2019-02-18T06:23:41+07:00",
"link": "https://[host]:[port]/viewtask?id=10"
},
{
"id": 10,
"desc": "New Assignment Item",
"due": "2019-02-18T06:23:41+07:00",
"link": "https://[host]:[port]/viewtask?id=10"
},
{
"id": 1,
"desc": "New Assignment Item",
"due": "2019-02-18T06:23:41+07:00",
"link": "https://[host]:[port]/viewtask?id=1"
},
{
"id": 33,
"desc": "New Assignment Item",
"due": "2019-02-18T06:23:41+07:00",
"link": "https://[host]:[port]/viewtask?id=33"
}
]
}
由于某些原因,重复了其中一个端点的响应之一。我已经尝试将请求触发到ESB上API的请求,但它总是会重复一个回复。您可以通过查看我的聚合调解器配置来帮助我,看看是否有任何错误?像往常一样感谢。
看来您的丰富调解人正在遇到问题。为了清楚地表明,我尝试解释一个示例,这并不是Aggregator
的工作原理,但可能会清楚出现问题的原因。通过接收第一个响应,它将//tasks
丰富到body
。通过收到第二个响应,您可能会猜到,body
在//tasks
下已经有一些东西,因此第二次汇总了两个//tasks
。
最好使用另一个属性而不是丰富身体。