Apache camel 输出正在重复,应仅打印一次

Apache camel 输出正在重复,应仅打印一次,apache-camel,camel-sql,Apache Camel,Camel Sql,这是一个来自mysql服务器的简单select语句,并在控制台上显示输出。不知怎的,结果被打印在循环中,尽管我没有使用任何计时器 <beans> <context:component-scan base-package="com.java"/> <bean destroy-method="close" class="org.apache.commons.dbcp.BasicDataSource" id="dataSource"> <property va

这是一个来自mysql服务器的简单select语句,并在控制台上显示输出。不知怎的,结果被打印在循环中,尽管我没有使用任何计时器

<beans>
<context:component-scan base-package="com.java"/>
<bean destroy-method="close" class="org.apache.commons.dbcp.BasicDataSource" id="dataSource">
<property value="com.mysql.jdbc.Driver" name="driverClassName"/>
<property value="jdbc:mysql://localhost:3306/world" name="url"/>
<property value="root" name="username"/>
<property value="mysql" name="password"/>
</bean>
<!-- configure the Camel SQL component to use the JDBC data source -->
<bean class="org.apache.camel.component.sql.SqlComponent" id="sql">
<property name="dataSource" ref="dataSource"/>
</bean>
<camel:camelContext>
<camel:route>
<camel:from uri="sql:select id from city where countryCode='AFG' and district ='Kabol' "/>
<camel:log message="${body[id]}"/>
<camel:to uri="stream:out"/>
</camel:route>
</camel:camelContext>
</beans>

默认情况下,fromsql将每隔500毫秒重复一次SQL调用(其计划时间)

如果希望SQL只触发一次,请使用计时器

from timer
to sql
并将计时器配置为仅运行一次

from timer
to sql