我正在尝试将 spring boot 与 camel 一起使用。在使用 camel routebuilder 定义路由时,似乎正在为一个路由定义创建两条路由。以下是项目设置的详细信息 -
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.10</version>
<relativePath />
</parent>
<dependencyManagement>
<dependencies>
<!-- Camel BOM -->
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-spring-boot-bom</artifactId>
<version>3.20.4</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-activemq</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-jms-starter</artifactId>
</dependency>
</dependencies>
路线建设者
@Component
public class MyRouteBuilder extends RouteBuilder{
@Override
public void configure() throws Exception {
from(jms:queue:queue11222?transacted=true&receiveTimeout=10000&connectionFactory=myconfactory).autoStartup(true)
.log("Received message from ESB queue: ${body}")
.log("JMS transaction set");
}
}
但是如果我从 RouteBuilder 类中删除“@Component”,则只会创建一个路由。根据这里的文档-https://camel.apache.org/camel-spring-boot/3.20.x/index.html;它提到用@Component注释RouteBuilder。
有人可以建议用 spring boot 配置 camel 以避免重复路由的推荐方法是什么吗?