代码之家  ›  专栏  ›  技术社区  ›  Aniket Garg

如何在apache camel路由xml中迭代arraylist?

  •  0
  • Aniket Garg  · 技术社区  · 8 年前

    我想遍历通过bean作为消息头传递给camel路由的java arraylist,这样每个基本上是url的字符串项都可以作为uri参数传递给camel路由中的标记。

    我通过java bean将数组列表作为消息头传递给camel路由,如下所示

    ArrayList<String> list=new ArrayList<String>();//Creating arraylist  
                  list.add("http://www.google.com");//Adding object in arraylist  
                  list.add("http://www.stackoverflow.com");  
                  list.add("http://www.tutorialspoint.com");  
                  list.add("http://localhost:8080/sampleExample/query"); 
                    exchange.getOut().setHeader("endpoints",list);
    

    <route id="myroute">
            <from id="sedp" uri="cxfrs:http://{{env:POC_HOST}}/{{env:POC_PATH}}"/>
            <log id="_log1" message="Received query request from consumers"/>
            <bean beanType="com.company.myapp.poc.logic.ProcessRequest"
                id="queryProcessor" method="checkRequestType"/>
    
              // I want to iterate through the list here as <toD uri="${header.endpoints.item}" />
    
    
        </route>
    

    但我无法遍历列表中作为标题接收的每个项目。驼峰路线内的端点。

    1 回复  |  直到 8 年前
        1
  •  0
  •   Claus Ibsen    8 年前

    这是收件人列表EIP模式,可以将消息发送到N个以上的目的地: http://camel.apache.org/recipient-list.html

    收件人列表EIP基本上是一个 toD toD 只能做1。

    它应该能够按原样接收消息头,例如 List Collection

    我也是

    <recipientList>
      <header>endpoints</header>
    </recipientList>