欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

rocketmq采坑: 连接异常 sendDefaultImpl call timeout

程序员文章站 2022-03-23 12:55:49
...

前提:

想使用rocketmq消息队列来做分布式事务处理的demo实验,安装完rocketmq后,并且启动namesrver, broker也成功了,但是使用springboot + rocketmq去连接时出现异常

环境:

centos7(172.xxx.xxx.251),rocketmq4.5.1,

springboot运行异常:

org.apache.rocketmq.remoting.exception.RemotingTooMuchRequestException: sendDefaultImpl call timeout
	at org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl.sendDefaultImpl(DefaultMQProducerImpl.java:640)
	at org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl.send(DefaultMQProducerImpl.java:1310)
	at org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl.send(DefaultMQProducerImpl.java:1256)
	at org.apache.rocketmq.client.producer.DefaultMQProducer.send(DefaultMQProducer.java:339)
	at com.hzy.rocketmq.rocketmqtransaction.client.RocketMQClient.defaultMQProducer(RocketMQClient.java:48)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:363)
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:307)
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:136)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:414)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1770)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:843)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775)
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:316)
2019-05-30 11:10:57.343	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260)
  INFO	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248)
 3952 	at com.hzy.rocketmq.rocketmqtransaction.RocketmqTransactionApplication.main(RocketmqTransactionApplication.java:10)
--- [lientSelector_1] RocketmqRemoting                         : closeChannel: close the connection to remote address[] result: true

分析:

连接超时,初步猜测

可能原因一:是端口之类的东西没开放,但是查看centos上网路防火墙也未开启,排除端口未开放问题;

可能原因二:broker已经启动成功,可能注册的ip有误

①查看管理页面的集群列表:http://172.xxx.xxx.251:8080/#/cluster,发现broker的地址是10.244.0.11,这个是服务器内网地址

rocketmq采坑: 连接异常 sendDefaultImpl call timeout

本地使用telnet 10.244.0.1 10911 可以发现明显的无法连接,所以需要修改broker的ip地址

处理:

#进入rocketmq  config目录,添加自定义配置
cd /opt/rocketmq/config/
#编写配置文件,并写好配置
echo "brokerIP1=172.xxx.xxx.251【服务器IP】" > broker.properties
#启动 mqnamesrv 
nohup sh bin/mqnamesrv &

#注意:mrbroker 启动时通过 -c 加载自定义配置文件
nohup sh bin/mqbroker -n 172.xxx.xxx.251:9876 -c /opt/rocketmq/config/broker.properties &

 停止RocketMQ命令
./bin/mqshutdown broker
./bin/mqshutdown namesrv

重启broker后,再次连接rocketmq,程序已经能正常连接了;果然接触新东西还是会踩不少雷

参考连接:https://www.cnblogs.com/smail-bao/p/6905460.html

安装使用可参考:https://www.cnblogs.com/ldy-blogs/p/10452422.html

相关标签: rocketmq