2016-11-14 72 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