使用嵌入式amqp开关弹簧靴和骆驼

时间:2018-01-29 12:34:40

标签: spring-boot apache-camel amqp

我想集成测试一个自定义的camel组件,因此需要一个嵌入式/内存混乱,我可以轻松地用于测试从/到端点。

我希望我能通过spring-boot-amqp-starter实现这一目标。 我使用this example作为开头,它具有依赖项:

 <dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-activemq</artifactId>
</dependency>
<dependency>
  <groupId>org.apache.activemq</groupId>
  <artifactId>activemq-broker</artifactId>
</dependency>
<dependency>
  <groupId>com.fasterxml.jackson.core</groupId>
  <artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
  <groupId>org.apache.camel</groupId>
  <artifactId>camel-spring-boot-starter</artifactId>
</dependency>

和配置:

spring:
  activemq:
    broker-url: vm://embedded?broker.persistent=false,useShutdownHook=false
   // ...

这是有效的,当我在春天使用常规的Listener注释时,我有一个发送者使用模板和消费者记录消息。

现在我更进一步使用camel,但它无法识别vm:embedded代理但尝试连接到未运行的tcp:// localhost。

return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("activemq:foo").to("log:sample");

            from("timer:bar").setBody(constant("Hello from Camel")).to("activemq:foo");
        }
    };

如何配置activemq-camel以使用嵌入式代理?

更新:

我使用spring-boot-dependencies的依赖关系管理导入(1.5.9) 和camel-spring-boot-dependencies(2.20.1)。

1 个答案:

答案 0 :(得分:1)

当您使用Spring Boot时,已在较新版本的activemq-camel中修复此问题。现在,activemq-camel组件将遵循spring.activemq.*设置的弹簧启动配置。