java ActiveMQ Artemis + Sping Boot 3 + Apache Camel - RouteBuilder不工作

6uxekuva  于 2023-05-12  发布在  Java
关注(0)|答案(1)|浏览(189)

我使用Apache Camel和ActiveMQ Artemis创建了一个非常简单的Sping Boot 3.0项目,因为ActiveMQ“Classic”支持在Spring Boot 3中已经停止。我的MQ路由不工作。任何帮助在这里真的很感激。
pom.xml依赖项:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>3.0.5</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>
<dependency>
    <groupId>org.apache.activemq</groupId>
    <artifactId>artemis-jms-client</artifactId>
    <version>2.28.0</version>
</dependency>
<dependency>
    <groupId>org.apache.camel.springboot</groupId>
    <artifactId>camel-jms-starter</artifactId>
    <version>3.20.2</version>
</dependency>
<dependency>
    <groupId>org.apache.camel.springboot</groupId>
    <artifactId>camel-spring-boot-starter</artifactId>
    <version>3.20.2</version>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-artemis</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>
@SpringBootApplication
public class ArtemisApplication {
    public static void main(String[] args) {
        SpringApplication.run(ArtemisApplication.class, args);
    }
}

application.properties

spring.artemis.broker-url=tcp://localhost:61616
camel.springboot.auto-startup=true
spring.artemis.password=admin
spring.artemis.user=admin
spring.artemis.mode=native
camel.servlet.mapping.context-path=/services/*

RouteBuilder类:

@Component
@Slf4j
public class ArtemisMQRouter extends RouteBuilder {
    @Override
    public void configure() throws Exception {
        from("activemq:queue:input")
                .routeId("ArtemisMQRouter ")
                .id("activemq:queue:input")
                .log(LoggingLevel.INFO, log, "Message received from activemq:queue:input")
                .to("activemq:queue:output")                
                .log(LoggingLevel.INFO, log, "Message successfully sent to the activemq:queue:output")
                .end();
    }
}
moiiocjp

moiiocjp1#

你需要Apache Camel v4来使用Sping Boot 3。Camel v3只兼容Sping Boot 2。

相关问题