2016-12-06 89 views
0

需要从套接字()读取数据,使用ibatis解析和写入数据库。这必须持续进行。不确定如何连续运行此过程。使用骆驼循环的想法。但它看起来像我们需要提及循环计数。在jboss保险丝上使用骆驼路由连续运行一个循环

<route id="vts-data"> 
    <from uri="timer://runOnce?repeatCount=1" /> 
    <doTry> 
     <loop> 
      <to uri="bean:vtsProcessor?method=extractLocations" /> 
      <log message="Details List is : ${body}" /> 
     </loop> 
     <choice> 
      <when> 
       <simple>${body.size} == 0</simple> 
       <log message="List is null ${body}" /> 
      </when> 
      <otherwise> 
       <to uri="mybatisPromis:insertLocationData?statementType=SelectList" /> 
       <log message="Details List is : ${body}" /> 
       <choice> 
        <when> 
         <simple>${body.size} == 0</simple> 
         <log message="Details List is null : ${body}" /> 
        </when> 
        <otherwise> 
         <log message="Details List is : ${body}" /> 
        </otherwise> 
       </choice> 
      </otherwise> 
     </choice> 
     <doCatch> 
      <exception>java.lang.Exception</exception> 
     </doCatch> 
     <doFinally> 
      <to uri="log:body" /> 
     </doFinally> 
    </doTry> 
</route> 

我是新来的骆驼和保险丝。认为使用工作线程连续运行过程,但不是运气。需要一些指针来做优化的方法。

回答

0

骆驼路线提供了“始终运行的过程”。它只是安排组件和EIP来满足您的要求。

  1. 推荐的方法是从插座中的“从”

  2. 如果不是#1,你应该看看使用pollingConsumer模式..定时器运行..轮询套接字端点读..然后持续到ibatis的

REF:http://camel.apache.org/polling-consumer.html