ActiveMq和Springboot

时间:2018-04-23 01:38:59

标签: java spring-boot activemq

我是春季启动的新手,正在尝试使用spring boot编写消费者

以下是我的代码:

application.properties
spring.activemq.broker-url=tcp://localhost:8161
spring.activemq.user=admin
spring.activemq.password=admin

SampleActiveMQApplication.java

@SpringBootApplication
@EnableJms
public class SampleActiveMQApplication {


    public static void main(String[] args) {
        SpringApplication.run(MicroserviceAddPayeeApplication.class, args);
    }
}

Consumer.java

@Component
public class Consumer {

    @JmsListener(destination = "queue/msgQueue")
    public void receiveQueue(String text) {
        System.out.println("inside consumer");
        System.out.println(text);
    }

}

我收到以下错误

2018-04-23 07:08:08.277  WARN 9196 --- [enerContainer-1] o.s.j.l.DefaultMessageListenerContainer  : Setup of JMS message listener invoker failed for destination 'queue/msgQueue' - trying to recover. Cause: Disposed due to prior exception
2018-04-23 07:08:08.292 ERROR 9196 --- [enerContainer-1] o.s.j.l.DefaultMessageListenerContainer  : Could not refresh JMS Connection for destination 'queue/msgQueue' - retrying using FixedBackOff{interval=5000, currentAttempts=0, maxAttempts=unlimited}. Cause: Cannot send, channel has already failed: tcp://127.0.0.1:8161

请协助:

1 个答案:

答案 0 :(得分:1)

您确定您的代理侦听您指定的端口8161吗?默认情况下,Active-mq管理控制台在浏览器上可访问的端口8161上进行侦听,而代理在61616上进行侦听。您可能需要确认。您可以查看更多信息here