rabbitmq出现的问题

An unexpected connection driver error occured
java.net.SocketException: socket closed异常

然后发现是自己rabbit连接时写错了

 

 有两个账户,写错了账户密码,然后出现了连接错误

 

发送短信时,队列里有消息没清空会报错

org.springframework.amqp.rabbit.listener.exception.ListenerExecutionFailedException

 

队列不存在时会报错

org.springframework.amqp.rabbit.listener.BlockingQueueConsumer$DeclarationException: Failed to declare queue(s):[sms_queue]

 

 

Execution of Rabbit message listener failed.

org.springframework.amqp.rabbit.support.ListenerExecutionFailedException: Listener method 'public void com.ifjanuary.mq.SendSmsCodeConsumer.reciver(java.lang.String)' threw exception
    at org.springframework.amqp.rabbit.listener.adapter.MessagingMessageListenerAdapter.invokeHandler(MessagingMessageListenerAdapter.java:228) ~[spring-rabbit-2.3.1.jar:2.3.1]
    at org.springframework.amqp.rabbit.listener.adapter.MessagingMessageListenerAdapter.invokeHandlerAndProcessResult(MessagingMessageListenerAdapter.java:148) ~[spring-rabbit-2.3.1.jar:2.3.1]
    at org.springframework.amqp.rabbit.listener.adapter.MessagingMessageListenerAdapter.onMessage(MessagingMessageListenerAdapter.java:133) ~[spring-rabbit-2.3.1.jar:2.3.1]
    at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:1632) ~[spring-rabbit-2.3.1.jar:2.3.1]
    at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.actualInvokeListener(AbstractMessageListenerContainer.java:1551) ~[spring-rabbit-2.3.1.jar:2.3.1]
    at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:1539) ~[spring-rabbit-2.3.1.jar:2.3.1]
    at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:1530) ~[spring-rabbit-2.3.1.jar:2.3.1]
    at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.executeListener(AbstractMessageListenerContainer.java:1474) ~[spring-rabbit-2.3.1.jar:2.3.1]
    at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.doReceiveAndExecute(SimpleMessageListenerContainer.java:966) [spring-rabbit-2.3.1.jar:2.3.1]
    at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.receiveAndExecute(SimpleMessageListenerContainer.java:912) [spring-rabbit-2.3.1.jar:2.3.1]
    at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.access$1600(SimpleMessageListenerContainer.java:83) [spring-rabbit-2.3.1.jar:2.3.1]
    at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.mainLoop(SimpleMessageListenerContainer.java:1287) [spring-rabbit-2.3.1.jar:2.3.1]
    at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:1193) [spring-rabbit-2.3.1.jar:2.3.1]
    at java.lang.Thread.run(Thread.java:748) [na:1.8.0_261]
Caused by: java.lang.NullPointerException: null
    at com.ifjanuary.util.RedisUtils.set(RedisUtils.java:37) ~[classes/:na]
    at com.ifjanuary.mq.SendSmsCodeConsumer.reciver(SendSmsCodeConsumer.java:21) ~[classes/:na]
    at sun.reflect.GeneratedMethodAccessor205.invoke(Unknown Source) ~[na:na]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_261]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_261]

https://blog.csdn.net/gaozhonghua12/article/details/97773801

https://blog.csdn.net/u014513883/article/details/77907898

感觉这个挺有用的https://www.codercto.com/a/31736.html

https://ask.csdn.net/questions/1062163

额。。最终发现是监听器没写对

@Component
public class StarterupListener implements ApplicationListener<ContextRefreshedEvent> {

    @Resource
    private RedisTemplate<String,Object> redisTemplate;

    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
        RedisUtils.register(redisTemplate);
    }

}

 

posted @ 2020-12-04 22:11  爱吃芒果的牛  阅读(1455)  评论(0编辑  收藏  举报