-
本人新手小白,想要做个个人博客,想尝试用springboot+activeMQ做一个小的功能,activeMQ的坑还是很多的,本人花了两天时间,才最终调好,遇到的各种问题在国内网站基本解决不了,还是推荐各位去google
-
基本的配置就不说了,百度还是很多的,下面列举一些问题,希望有所帮助。
-
Correct the classpath of your application so that it contains a single, compatible version of org.springframework.jms.config.DefaultJmsListenerContainerFactory
解决办法:@Bean
public DefaultJmsListenerContainerFactory jmsListenerContainerFactory(ConnectionFactory connectionFactory, SomeHandler errorHandler) {
DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
factory.setConnectionFactory(connectionFactory());
factory.setConcurrency(“1-1”);
factory.setErrorHandler(errorHandler);
return factory;
}
第二个问题:ActiveMQ接收消息报未设置响应目标
org.springframework.jms.listener.adapter.ReplyFailureException: Failed to send reply with payload [123]; nested exception is javax.jms.InvalidDestinationException: Cannot determine response destination: Request message does not contain reply-to destination, and no default response destination set.
at org.springframework.jms.listener.adapter.AbstractAdaptableMessageListener.handleResult(AbstractAdaptableMessageListener.java:249) ~[activemq-all-5.13.0.jar:5.13.0]
at org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter.onMessage(MessagingMessageListenerAdapter.java:68) ~[activemq-all-5.13.0.jar:5.13.0]
at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:689) ~[activemq-all-5.13.0.jar:5.13.0]
at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:649) ~[activemq-all-5.13.0.jar:5.13.0]
at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:619) ~[activemq-all-5.13.0.jar:5.13.0]
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:307) [activemq-all-5.13.0.jar:5.13.0]
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:245) [activemq-all-5.13.0.jar:5.13.0]
at org.springframework.jms.listener.DefaultMessageListenerContainerAsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1136) [activemq-all-5.13.0.jar:5.13.0]
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:1033) [activemq-all-5.13.0.jar:5.13.0]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_144]
Caused by: javax.jms.InvalidDestinationException: Cannot determine response destination: Request message does not contain reply-to destination, and no default response destination set.
at org.springframework.jms.listener.adapter.AbstractAdaptableMessageListener.getResponseDestination(AbstractAdaptableMessageListener.java:331) ~[activemq-all-5.13.0.jar:5.13.0]
at org.springframework.jms.listener.adapter.AbstractAdaptableMessageListener.handleResult(AbstractAdaptableMessageListener.java:245) ~[activemq-all-5.13.0.jar:5.13.0]
… 10 common frames omitted
解决办法:
第三个问题:
Execution of JMS message listener failed, and no ErrorHandler has been set.
解决办法:在配置类中加入
如果是默认工厂直接在
推荐链接:https://www.devglan.com/spring-boot/spring-boot-jms-activemq-example
整体搭建深受启发。