简体   繁体   English

收件人列表Apache Camel EIP

[英]RecipientList Apache Camel EIP

I'm trying to use the RecipientList pattern in Camel but I think I may be missing the point. 我正在尝试在Camel中使用RecipientList模式,但我想我可能会遗漏了这一点。 The following code only displays one entry to the screen: 以下代码仅在屏幕上显示一个条目:

@Override
protected RouteBuilder createRouteBuilder() {
    return new RouteBuilder() {
        public void configure() {
            from("direct:start").recipientList(bean(MyBean.class, "buildEndpoint"))
                    .streaming()
                    .process(new Processor() {
                        @Override
                        public void process(Exchange exchange) throws Exception {
                            System.out.println(exchange.getExchangeId());
                        }
                    });
        }
    };
}

public static class MyBean {
    public static String[] buildEndpoint() {
        return new String[] { "exec:ls?args=-la", "exec:find?args=."};
    }
}

I also tried just returning a comma-delimited string from the buildEndpoint() method and using tokenize(",") in the expression of the recipientList() component definition but I still got the same result. 我还尝试仅从buildEndpoint()方法返回逗号分隔的字符串,并在accepterList()组件定义的表达式中使用tokenize(“,”),但仍然得到相同的结果。 What am I missing? 我想念什么?

That is expected, the recipient list sends a copy of the same message to X recipients. 可以预期,收件人列表会将相同消息的副本发送给X个收件人。 The processor you do afterwards is doing after the recipient lists is done, and therefore is only executed once. 收件人列表完成 ,您之后要做的处理器将执行,因此仅执行一次。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM