Apache camel 关闭camel时出现批插入问题

Apache camel 关闭camel时出现批插入问题,apache-camel,Apache Camel,我使用mybatis在mysql中进行批插入。我不断向ArrayList添加消息,并在ArrayList大小达到批大小时触发查询 <route id="billingRoute"> <from uri="activemq:queue:{{billing.queue}}" /> <log message="Message received from billing queue is ${body}"></log> <unmarshal ref

我使用mybatis在mysql中进行批插入。我不断向ArrayList添加消息,并在ArrayList大小达到批大小时触发查询

<route  id="billingRoute">
<from uri="activemq:queue:{{billing.queue}}" />
<log message="Message received from billing queue is ${body}"></log>
<unmarshal ref="gsonBilling"></unmarshal>
<bean beanType="com.bng.upload.processors.GetCdr" method="process(com.bng.upload.beans.BillingEvent,${exchange})" />
log message="Multicasting  data ${body} to file system and database" />
<multicast>
<pipeline>
<transform>
<method ref="insertionBean" method="billingBatchInsertion"></method>
</transform>
<choice>
<when>
<simple> ${body.size()} == ${properties:batch.size}</simple>
<to uri="mybatis:batchInsertBilling?statementType=InsertList"></to>
<log message="Inserted in billing table : ${in.header.CamelMyBatisResult}"></log>
</when>
</choice>
</pipeline>
<pipeline>
<choice>
<when>
<simple>${properties:billing.write.file} == true</simple>
<setHeader headerName="path">
<simple>${properties:billing.cdr.folder}</simple>
</setHeader>
<log message="Going to write to file : ${body}"></log>
<bean beanType="com.bng.upload.processors.ToFile"
method="process(${exchange},com.bng.upload.beans.BillingCdr)" />
<to uri="file://?fileExist=Append"></to>
</when>
</choice>
</pipeline>
</multicast>
</route>
</routeContext>

log message=“将数据${body}多播到文件系统和数据库”/>
${body.size()}==${properties:batch.size}
${properties:billing.write.file}==true
${properties:billing.cdr.folder}

我们不使用事务,因为路由文件、ActiveMq和数据库中包含多个组件。问题是,当tomcat重新启动时,如果ArrayList大小没有达到批处理大小,那么这些消息就会丢失。有什么解决方案吗

我不知道我是否理解,即使在托管Camel的tomcat重新启动之后,您也希望保持一个状态?基本上,即使在重启后,您仍希望继续您中断的位置?是的,我们希望这样做。现在我们正在将列表保存在redis中,直到它被插入到db中。我不确定是否理解,即使在托管Camel的tomcat重启后,您仍希望保持一种状态?基本上,即使重新启动后,您仍希望继续您中断的位置?是的,我们希望这样做。现在,我们正在将列表保存在redis中,直到将其插入db。