【发布时间】:2019-03-06 12:00:23
【问题描述】:
我在 Spring Boot 2 上通过 Apache Camel 连接到 rabbitmq 时遇到问题。
我做了以下步骤:
我的依赖:
implementation "org.apache.camel:camel-spring-boot-starter:${camelVersion}"
implementation "org.apache.camel:camel-jackson-starter:${camelVersion}"
implementation "org.apache.camel:camel-core:${camelVersion}"
implementation "org.apache.camel:camel-rabbitmq-starter:${camelVersion}"
implementation "org.springframework.boot:spring-boot-starter-amqp"
Application.yaml
spring:
rabbitmq:
dynamic: true
host: 192.168.1.1
port: 5672
username: X
password: Y
我有以下路线:
@Component
public class BasicRoute extends RouteBuilder {
@Override
public void configure() throws Exception {
from("direct:loggerQueue")
.id("loggerQueue")
.to("rabbitmq://TEST-QUEUE.exchange?queue=TEST-QUEUE.queue&autoDelete=false&connectionFactory=#rabbitConnectionFactory")
.end();
}
}
最后我还有以下问题:
2019-03-06 12:46:05.766 WARN 19464 --- [restartedMain] o.a.c.c.rabbitmq.RabbitMQProducer:无法创建连接。发布消息时它将尝试再次连接。 java.net.ConnectException:连接被拒绝:连接
连接似乎没问题,我测试了它。 rabbitConnectionFactory 出了点问题。
我不知道自己有什么不好。
【问题讨论】:
-
您是否尝试将属性前缀从
spring.rabbit更改为camel.component.rabbitmq? -
还是同样的错误。
标签: java spring spring-boot rabbitmq apache-camel