Apache的骆驼SQL组件 - 如何只执行一次 [英] apache camel sql component - how to execute only once
问题描述
我创建/创建一个简单的Apache的骆驼程序从一个源移动数据DB到目标数据库。我已经配置做到这一点的路线和它的作品!的问题是,它只是不断执行根每一秒左右。我只希望它执行一次。
I've created/creating a simple Apache Camel program to move data from a source db to a target db. I have configured a route to do this and it works! The problem is that it just keeps executing the root every second or so. I only want it to execute once.
我一直在玩弄定时器的repeatCount,但不能完全得到根本的权利。谁能帮我尝试重新字我下面,使其只执行一次。
I've been playing around with the timer repeatCount but can't quite get the root right. Can anyone help me to try and re-word what i have below so that it only executes once.
<bean id="sourceSql" class="org.apache.camel.component.sql.SqlComponent">
<property name="dataSource" ref="sourceDataSource"/>
</bean>
<bean id="targetSql" class="org.apache.camel.component.sql.SqlComponent">
<property name="dataSource" ref="targetDataSource"/>
</bean>
<camelContext xmlns="http://camel.apache.org/schema/spring">
<propertyPlaceholder location="classpath:sql.properties" id="placeholder"/>
<route id="processProduct-route">
<description>route that process the orders by picking up new rows from the database
and when done processing then update the row to mark it as processed</description>
<from uri="sourceSql:{{sql.selectProduct}}"/>
<to uri="targetSql:{{sql.insertProduct}}"/>
<log message="${body}"/>
</route>
在此先感谢
推荐答案
您可以从路线停止路线,请参阅:的 http://camel.apache.org/how-can-i-stop-a-route-from-a-route.html 一>
You can stop a route from a route, see: http://camel.apache.org/how-can-i-stop-a-route-from-a-route.html
尽管在骆驼2.11起还可以将消息发送到一个控制总线端点可以是更简单的。所以,你可以在路由ENDP发送到此端点。
Though in Camel 2.11 onwards you can also send a message to a controlbus endpoint which can be simpler. So you can send to this endpoint at the endp of the route.
<route id="processProduct-route">
<description>route that process the orders by picking up new rows from the database
and when done processing then update the row to mark it as processed</description>
<from uri="sourceSql:{{sql.selectProduct}}"/>
<to uri="targetSql:{{sql.insertProduct}}"/>
<log message="${body}"/>
<to uri="controlbus:route?routeId=processProduct-route&action=stop&async=true"/>
</route>
这篇关于Apache的骆驼SQL组件 - 如何只执行一次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!