apache camel sql组件 - 如何只执行一次 [英] apache camel sql component - how to execute only once
问题描述
我创建/创建了一个简单的 Apache Camel 程序,用于将数据从源数据库移动到目标数据库.我已经配置了一个路线来做到这一点,它的工作原理!问题是它只是每秒左右执行一次root.我只希望它执行一次.
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
尽管在 Camel 2.11 之后的版本中,您也可以将消息发送到更简单的 controlbus 端点.所以你可以在路由的 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 camel sql组件 - 如何只执行一次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!