Apache camel 如何使用camel recipentList

Apache camel 如何使用camel recipentList,apache-camel,Apache Camel,我只是试着用RecipentList让骆驼路线工作。但首先是一个问题:两者之间的区别是什么 多播/RecipentList(两者都没有并行处理) 多个“到” ? 在我的例子中,我希望对一些路由进行并行处理。目前都使用多个 在for循环中添加“to”: RouteDefinition someRoute = createSomeRout(fromPart, id); \\ method for (String pcrfTarget : cepConfig.pcrfCepTargets()) {

我只是试着用RecipentList让骆驼路线工作。但首先是一个问题:两者之间的区别是什么

  • 多播/RecipentList(两者都没有并行处理)
  • 多个“到” ?
在我的例子中,我希望对一些路由进行并行处理。目前都使用多个

在for循环中添加“to”:

RouteDefinition someRoute = createSomeRout(fromPart, id); \\ method
for (String pcrfTarget : cepConfig.pcrfCepTargets()) {
    log.info("...to " + pcrfTarget);
    someRoute.to(pcrfTarget + "?mode=" + Mode.insertAddId.name());
}
是否有一种直接的方法可以使用recipientList并在末尾添加parallelProcessing? 我还尝试创建一个简单的示例,但失败了(图书和互联网中唯一的示例是使用/操作标题:-()。下面是我的示例(错误):

我得到一个错误:

org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[EDR_UPCC244_MPU842_0370_20140428000008.csv.gz]
...
Caused by: java.lang.AssertionError: expected null, but was:<[B@48d19957>
org.apache.camel.cameleExecutionException:在exchange上执行时发生异常:exchange[EDR_UPCC244_MPU842_0370_20140428000008.csv.gz]
...
原因:java.lang.AssertionError:应为null,但为:
我认为出于某种原因,camel试图使用文件内容获取收件人?!有人能提供一个示例,说明如何动态创建recipentList,但不是基于exchange附带的数据,而是基于独立数据(在配置中给出了我的示例)


感谢您将
RecipientList
RecipientList()
混合在一起是不可能的,如(使用方法调用作为收件人列表)一节所述。因此,只需使用其中一个

1.使用recipientList()

从方法中删除
@RecipientList

// No @RecipientList annotation
public String[] recipents() {
    return new String[] { MOCK1, MOCK2 };
}
并将路线定义如下:

from("direct:start")
    .recipientList()
    .method(Experiments.class)  // you may define a method name as well if there is more than one
    .parallelProcessing();
或:

2.使用@RecipientList

@RecipientList
bean
一起使用:

from("direct:start")
    .bean(Experiments.class);  // you may define a method name as well if there is more than one
要实现并行处理,需要将
parallelProcessing
属性添加到
@RecipientList
注释中:

@RecipientList(parallelProcessing = true)
public String[] recipents() {
    return new String[] { MOCK1, MOCK2 };
}
from("direct:start")
    .bean(Experiments.class);  // you may define a method name as well if there is more than one
@RecipientList(parallelProcessing = true)
public String[] recipents() {
    return new String[] { MOCK1, MOCK2 };
}