2016-11-14 67 views
0

我有一个要求,我想在Apache Camel中使用mutlicast,而不是单一路由中的单个时间。即组播中的多播。我们可以在apache骆驼中使用多个mutlicast吗?

<routeContext id="myRoute" xmlns="http://camel.apache.org/schema/spring"> 
     <route id="myRouteId"> 
      <from uri="activemq:queue:{{XXXX.queue}}" /> 
     .... 
      <multicast parallelProcessing="true"> 
       <pipeline> 
        ##everything working fine here 
       </pipeline> 
       <pipeline> 
        <multicast> 
         <pipeline> 
          <log message="Inserting in database now"></log> 
          <transform> 
           <method ref="insertBean" method="myBatchInsertion"></method> 
          </transform> 
           <choice> 
           <when> 
            <simple>${in.header.myCount} == ${properties:batch.size} </simple> 
            <to uri="sql:{{sql.core.insertMyQuery}}?batch=true"></to> 
            <log message="Inserted rows ${body}"></log> 
           </when> 
          </choice> 
         </pipeline> 
        </multicast> 
        </pipeline> 
       </multicast> 
      </route> 
     </routeContext> 

有没有可能这样做? 当我试图做到这一点时,我的程序没有成功执行。 不成功的执行是多重多播的结果吗? 任何人都可以帮忙吗? 我从以下链接获得参考: http://camel.apache.org/multicast.html

+0

没有放弃知道我跟着,你可以用一些代码来显示你想达到,即使它没有运行什么编辑您的问题吗? –

回答

0

为什么使用管道?它默认是“管道”。

所有的日志和转换和选择语句都可以放在多播之外。而且,由于您正在动态生成您的端点,因此请将这些值放在标题中,并使用收件人列表为动态端点。多播用于硬编码的端点。这里有一个例子:

<route> 
    <from uri="direct:a" /> 
    <!-- use comma as a delimiter for String based values --> 
    <recipientList delimiter=","> 
    <header>myHeader</header> 
    </recipientList> 
</route> 

http://camel.apache.org/recipient-list.html

+1

我有多个进程在内部多播下运行,这就是为什么我使用管道。 – KayV