【发布时间】:2019-03-27 20:36:21
【问题描述】:
Java 8 和 Apache Camel 2.19.5 在这里。我有以下 bean 处理器:
@Component("foobarResolver")
public class FoobarResolver {
public List<Foobar> resolve(Fizzbuzz fizzbuzz) {
List<Foobar> foobars = new ArrayList<Foobar>();
// Use some logic in here to make the fizzbuzz populate the foobars list.
return foobars;
}
}
@Component("fizzbuzzProcessor")
public class FizzbuzzProcessor {
public FizzbuzzOutput process(Fizzbuzz fizzbuzz) {
// Blah whatever
}
}
还有以下骆驼路线:
<route id="fizzbuzzHandler">
<!-- XML '<fizzbuzz>' messages get sent here by an upstream process -->
<from uri="activemq:fizzbuzzes"/>
<!-- Use XStream to deserialize the XML into a 'Fizzbuzz' POJO instance -->
<unmarshal ref="xs"/>
<split>
<method ref="bean:foobarResolver"/>
<to uri="activemq:analyze"/>
</split>
<!-- Now assuming our body is once again the Fizzbuzz we can just continue as normal... -->
<!-- Process the fizzbuzz -->
<to uri="bean:fizzbuzzProcessor"/>
<!-- Send fizzbuzzProcessor's output to 'output' queue -->
<to uri="activemq:output"/>
</route>
如您所见,反序列化的Fizzbuzz 实例被发送到FoobarResolver bean 处理器,该处理器将该实例转换为List<Foobar>,然后将每个Foobar 发送到analyze 队列,一个一个。至少这就是我的设计意图!
我很好奇的是:分裂之后,交换体变成了什么?它是“还原”回Fizzbuzz(这是我想要的),还是现在是FoobarResolver 产生的List<Foobar>(这不是我想要的)?如果正文现在是List<Foobar>,我该如何重新配置,让FizzbuzzProcessor 接收Fizzbuzz?
【问题讨论】:
标签: java apache-camel integration-patterns