使用嵌入式 amqp swith spring boot 和 camel
using embedded amqp swith spring boot and camel
我想集成测试一个自定义的 camel 组件,因此需要一个 embedded/in 内存消息,我可以轻松地使用它来测试 from/to 端点。
我希望我可以通过 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
// ...
这是有效的,当我在 spring 中使用常规监听器注释时,我有一个使用模板的发件人和一个记录消息的消费者。
现在我更进一步并使用 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).
当您将它与 Spring Boot 一起使用时,这已在较新版本的 activemq-camel 中得到修复。现在 activemq-camel 组件将遵循 spring.activemq.*
设置的 spring 启动配置。
我想集成测试一个自定义的 camel 组件,因此需要一个 embedded/in 内存消息,我可以轻松地使用它来测试 from/to 端点。
我希望我可以通过 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
// ...
这是有效的,当我在 spring 中使用常规监听器注释时,我有一个使用模板的发件人和一个记录消息的消费者。
现在我更进一步并使用 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).
当您将它与 Spring Boot 一起使用时,这已在较新版本的 activemq-camel 中得到修复。现在 activemq-camel 组件将遵循 spring.activemq.*
设置的 spring 启动配置。