首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >在多播中将Camel处理器分组或批处理在一起

在多播中将Camel处理器分组或批处理在一起
EN

Stack Overflow用户
提问于 2019-03-21 03:00:10
回答 2查看 24关注 0票数 0

Java 8和Apache Camel 2.19.5。我想定义一个路由(使用Spring XML DSL)来完成以下任务:

  1. 使用来自ActiveMQ的消息,将来自字符串的XML消息从字符串发送到Fizzbuzz实例
  2. 将该Fizzbuzz发送到FoobarGenerator处理器
  3. <代码>D11处理器在Foobar消息的exchange
  4. Copies上生成Foobar,然后同时传递到两个下游处理器:(a) D16处理器和(b) D17处理器6a。Configurator处理Foobar并将一些结果存储在DB 6b中。Analyzer处理Foobar,然后路由将该实例发送到反序列化程序(返回到字符串中),然后将该字符串发送到另一个AMQ queue

这是我到目前为止所知道的:

<route id="fizzbuzz_processor">
  <!-- Step 1: Consume Fizzbuzz XML from AMQ -->
  <from uri="activemq:fizzbuzzes"/>

  <!-- Step 2: Deserialize into Fizzbuzz POJO instance, using XStream -->
  <unmarshall ref="xs"/>

  <!--
    Step 3 + 4: Send to FoobarGenerator processor;
    output is a 'Foobar' POJO instance
  -->
  <to uri="bean:foobarGenerator"/>

  <!-- Step 5: Send Foobar to two places at the same time -->
  <multicast>
    <!-- Step 6a: Foobar goes to Configurator processor -->
    <to uri="bean:configurator"/>

    <!-- Step 6b: Foobar also goes to Analyzer processor -->
    <to uri="bean:analyzer"/>

    <!--
      AFTER Analyzer, Foobar gets serialized into XML and sent
      to another queue
    -->
    <marshall ref="xs"/>
    <to uri="activemq:foobars"/>
  </multicast>
</route>

这种设置的问题在于,据我所知,multicasters只能定义为它们将向其发送消息的顶级端点。因此,按照我上面配置的方法,多播将发送消息到:(a) bean:configurator,(b) bean:analyzer,(c) XStream/marshaller,和(d) activemq:fizzbuzzes,而不是同时发送到bean:configurator和bean:analyzer,然后在bean:analyzer之后,编组并发送到。

如何重新配置此路由以执行我想要的操作?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2019-03-27 09:04:22

事实证明你可以这样做:

<route id="fizzbuzz_processor">
  <!-- Step 1: Consume Fizzbuzz XML from AMQ -->
  <from uri="activemq:fizzbuzzes"/>

  <!-- Step 2: Deserialize into Fizzbuzz POJO instance, using XStream -->
  <unmarshall ref="xs"/>

  <!--
    Step 3 + 4: Send to FoobarGenerator processor;
    output is a 'Foobar' POJO instance
  -->
  <to uri="bean:foobarGenerator"/>

  <!-- Step 5: Send Foobar to two places at the same time -->
  <multicast parallelProcessing="true">
    <!-- Step 6a: Foobar goes to Configurator processor -->
    <to uri="bean:configurator"/>

    <!-- Step 6b: Foobar also goes to Analyzer processor -->
    <to uri="direct:someOtherRoute"/>
  </multicast>
</route>

其中direct:someOtherRoute转到另一条实现我所描述的6b之后的所有内容的路由,而boom您已经同时多播到了这两个“地方”。

票数 0
EN

Stack Overflow用户

发布于 2019-03-22 15:47:01

为什么要使用多播弹性公网EIP?看起来你可以得到同样的结果,或者通过完全删除多播,例如:

<route id="fizzbuzz_processor">
  <!-- Step 1: Consume Fizzbuzz XML from AMQ -->
  <from uri="activemq:fizzbuzzes"/>
  <!-- Step 2: Deserialize into Fizzbuzz POJO instance, using XStream -->
  <unmarshall ref="xs"/>
  <!--
    Step 3 + 4: Send to FoobarGenerator processor;
    output is a 'Foobar' POJO instance
  -->
  <to uri="bean:foobarGenerator"/>

  <!-- Step 6a: Foobar goes to Configurator processor -->
  <to uri="bean:configurator"/>

  <!-- Step 6b: Foobar also goes to Analyzer processor -->
  <to uri="bean:analyzer"/>
  <marshall ref="xs"/>
  <to uri="activemq:foobars"/>
</route>

或者通过将marshal/activemq部分留在多播之外。Camel应该完成多路广播,然后继续执行marshal/to。

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55268331

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档