Spring boot 驼峰弹簧引导:执行后路由不会停止
我正在使用SpringBoot+Camel进行以下配置 主类 应用程序属性 pom.xml 由于camel.springboot.main-run-controller属性,我的Spring Boot在无限循环中运行路由执行SELECT查询,直到我点击CNTRL+C。如果删除此属性,应用程序将立即启动并停止路由,而不会完成执行 有人能帮助我,在我运行Spring Boot应用程序时开始、执行步骤并停止吗?添加。停止: 添加.停止:Spring boot 驼峰弹簧引导:执行后路由不会停止,spring-boot,apache-camel,camel-sql,Spring Boot,Apache Camel,Camel Sql,我正在使用SpringBoot+Camel进行以下配置 主类 应用程序属性 pom.xml 由于camel.springboot.main-run-controller属性,我的Spring Boot在无限循环中运行路由执行SELECT查询,直到我点击CNTRL+C。如果删除此属性,应用程序将立即启动并停止路由,而不会完成执行 有人能帮助我,在我运行Spring Boot应用程序时开始、执行步骤并停止吗?添加。停止: 添加.停止: 您可以使用spring引导属性: # handle only o
您可以使用spring引导属性:
# handle only one 1 message and then stop the route
camel.springboot.duration-max-messages=1
# run for 180 seconds and then gracefully shutdown
camel.springboot.duration-max-seconds=180
# a polling consumer will cancel the graceful shutdown so set the shutdownTimeout to a minimum
camel.springboot.shutdownTimeout=1
您可以使用spring引导属性:
# handle only one 1 message and then stop the route
camel.springboot.duration-max-messages=1
# run for 180 seconds and then gracefully shutdown
camel.springboot.duration-max-seconds=180
# a polling consumer will cancel the graceful shutdown so set the shutdownTimeout to a minimum
camel.springboot.shutdownTimeout=1
您只想从数据库中选择一次,然后处理并停止?是的,我希望我的路由运行一次执行我的选择、查询过程并停止。使用计时器并告诉它运行一次,然后您可以从路由停止路由:很遗憾,链接没有帮助,因为只有一条错误消息而不是代码:错误格式化宏:snippet:java.lang.IndexOutOfBoundsException:Index:20,Size:20。所以我看不出应该做什么:-你只想从数据库中选择一次,然后处理并停止吗?是的,我希望我的路由运行一次执行我的选择、查询过程并停止。使用计时器并告诉它运行一次,然后你可以从路由停止路由:不幸的是,链接没有帮助,因为只有一条错误消息而不是代码:错误格式化宏:snippet:java.lang.IndexOutOfBoundsException:Index:20,Size:20。因此,我看不出应该做什么:-这根本没有帮助,因为。stop仅将当前exchange标记为completet并停止进一步路由这根本没有帮助,因为。stop仅将当前exchange标记为completet并停止进一步路由
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.abc</groupId>
<artifactId>wl-event-notification-batch</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>notification</name>
<description></description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<!-- Camel -->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<version>2.17.2</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring</artifactId>
<version>2.17.2</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-stream</artifactId>
<version>2.17.2</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-sql</artifactId>
<version>2.17.2</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jdbc</artifactId>
<version>2.17.2</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring-boot</artifactId>
<version>2.17.2</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring-boot-starter</artifactId>
<version>2.17.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
public void configure() throws Exception {
from("sql:{{list.sql}}?dataSource=#dataSource")
.log("process row ${body}")
.stop();
}
# handle only one 1 message and then stop the route
camel.springboot.duration-max-messages=1
# run for 180 seconds and then gracefully shutdown
camel.springboot.duration-max-seconds=180
# a polling consumer will cancel the graceful shutdown so set the shutdownTimeout to a minimum
camel.springboot.shutdownTimeout=1