聚合来自两个不同消费者的两条JMS消息

时间:2014-11-16 17:37:56

标签: jms mule aggregate

我有两个jms消费者,每个消费者都有不同的流程。我想使用另一个流来聚合这两条消息的消息。并且还需要保持相关性Ids,因为我需要拆分有效载荷并发回消息。

    <flow name="integration-consumer-client1" doc:name="integration-consumer-client1">
    <jms:inbound-endpoint doc:name="JMS" connector-ref="Active_MQ" queue="client1.publish"/>
    <logger message="Consumes Client One = #[payload]" level="INFO" doc:name="Logger"/>
    <logger message="Client One Correlation = #[message.correlationId]" level="INFO" doc:name="Logger"/>
    <vm:outbound-endpoint exchange-pattern="one-way" path="client1" doc:name="VM"/>
</flow>
<flow name="integration-consumer-client2" doc:name="integration-consumer-client2">
    <jms:inbound-endpoint doc:name="JMS" connector-ref="Active_MQ" queue="client2.publish"/>
    <logger message="Consumes Client Two = #[payload]" level="INFO" doc:name="Logger"/>
    <logger message="Client Two Correlation = #[message.correlationId]" level="INFO" doc:name="Logger"/>
    <vm:outbound-endpoint exchange-pattern="one-way" path="client2" doc:name="VM"/>
</flow>
<flow name="integration-internetsolutionsFlow1" doc:name="integration-internetsolutionsFlow1">
    <scatter-gather doc:name="Scatter-Gather">
        <vm:inbound-endpoint exchange-pattern="one-way" path="client1" doc:name="VM"/>
        <vm:inbound-endpoint exchange-pattern="one-way" path="client2" doc:name="VM"/>
    </scatter-gather>
</flow>

我尝试将散布集合与两个入站虚拟机一起使用但出现以下错误:

由以下原因引起:org.xml.sax.SAXParseException:cvc-complex-type.2.4.a:找到以元素&#39; vm:inbound-endpoint&#39;开头的无效内容。其中一个{&#34; http://www.mulesoft.org/schema/mule/core&#34;:注释,&#34; http://www.mulesoft.org/schema/mule/core&#34;:自定义聚合策略,&#34; {{3 }&#34;:threading-profile,&#34; http://www.mulesoft.org/schema/mule/core&#34;:abstract-message-processor,&#34; http://www.mulesoft.org/schema/mule/core&#34;:abstract-outbound-endpoint ,&#34; http://www.mulesoft.org/schema/mule/core&#34;:abstract-mixed-content-message-processor}&#39;是期待。     at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)

1 个答案:

答案 0 :(得分:1)

错误的原因是 integration -internetsolutionsFlow1 没有任何入站端点..

您可以做的是: -

从两个流中使用vm:outbound-endpoint到相同路径     integration-consumer-client1 integration-consumer-client2

然后在 integration -internetsolutionsFlow1

     <flow name="integration-internetsolutionsFlow1" doc:name="integration-internetsolutionsFlow1">
      <vm:inbound-endpoint exchange-pattern="request-response" path="Your Path" doc:name="VM" connector-ref="vmConnector" />
    <logger level="INFO" message="#[message.payload]" doc:name="Logger"/>
<!-- you don't require a setter-getter here -->
    </flow>

来自流 integration-consumer-client1 integration-consumer-client2 的出站VM的路径应该相同..

这里不需要分散 - 聚集..因为两个流都会将有效负载分解为相同的VM路径..它将由VM入站端点接收