某天開發同事報說rocketmq鏈接不了,報如下錯誤:apache
org.apache.rocketmq.remoting.exception.RemotingTooMuchRequestException: sendDefaultImpl call timeout
本着凡事都要親自驗證的原則,我登錄rocketmq服務器作了測試:
bash
[root@test-server rocketmq]# export NAMESRV_ADDR=localhost:9876 [root@test-server rocketmq]# sh bin/tools.sh org.apache.rocketmq.example.quickstart.Producer 16:38:41.675 [main] DEBUG i.n.u.i.l.InternalLoggerFactory - Using SLF4J as the default logging framework RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.PlatformDependent0). RocketMQLog:WARN Please initialize the logger system properly. SendResult [sendStatus=SEND_OK, msgId=AC110001DBD94D7E1886279EDA940000, offsetMsgId=0A01066600002A9F0000000000D57A02, messageQueue=MessageQueue [topic=TopicTest, brokerName=nacos_test, queueId=3], queueOffset=2232] SendResult [sendStatus=SEND_OK, msgId=AC110001DBD94D7E1886279EDAB50001, offsetMsgId=0A01066600002A9F0000000000D57ACB, messageQueue=MessageQueue [topic=TopicTest, brokerName=nacos_test, queueId=0], queueOffset=2231] SendResult [sendStatus=SEND_OK, msgId=AC110001DBD94D7E1886279EDABA0002, offsetMsgId=0A01066600002A9F0000000000D57B94, messageQueue=MessageQueue [topic=TopicTest, brokerName=nacos_test, queueId=1], queueOffset=2231] SendResult [sendStatus=SEND_OK, msgId=AC110001DBD94D7E1886279EDAC50003, offsetMsgId=0A01066600002A9F0000000000D57C5D, messageQueue=MessageQueue [topic=TopicTest, brokerName=nacos_test, queueId=2], queueOffset=2233] SendResult [sendStatus=SEND_OK, msgId=AC110001DBD94D7E1886279EDAC90004, offsetMsgId=0A01066600002A9F0000000000D57D26, messageQueue=MessageQueue [topic=TopicTest, brokerName=nacos_test, queueId=3], queueOffset=2233]
[root@test-server rocketmq]# sh bin/tools.sh org.apache.rocketmq.example.quickstart.Consumer 9EDD1600A6, CLUSTER=DefaultCluster, WAIT=true, TAGS=TagA}, body=[72, 101, 108, 108, 111, 32, 82, 111, 99, 107, 101, 116, 77, 81, 32, 49, 54, 54], transactionId='null'}]] ConsumeMessageThread_3 Receive New Messages: [MessageExt [brokerName=nacos_test, queueId=1, storeSize=203, queueOffset=2266, sysFlag=0, bornTimestamp=1620463122633, bornHost=/10.1.6.105:43826, storeTimestamp=1620463122631, storeHost=/10.1.6.102:10911, msgId=0A01066600002A9F0000000000D5EA2E, commitLogOffset=14019118, bodyCRC=174475622, reconsumeTimes=0, preparedTransactionOffset=0, toString()=Message{topic='TopicTest', flag=0, properties={MIN_OFFSET=0, MAX_OFFSET=2281, CONSUME_START_TIME=1620463196672, UNIQ_KEY=AC110001DBD94D7E1886279EDCC9008E, CLUSTER=DefaultCluster, WAIT=true, TAGS=TagA}, body=[72, 101, 108, 108, 111, 32, 82, 111, 99, 107, 101, 116, 77, 81, 32, 49, 52, 50], transactionId='null'}]]
發現生產者和消費者均可以正常工做,因而跟開發說我這邊測試沒問題,開發又把日誌發過來,確實不行。因而我懷疑是否是就本機能夠,別的機器訪問他不行,我就在另一臺機器上作了測試,果真不行,報的錯跟開發提供的同樣。因爲此前也沒用過這玩意兒,不是很熟,遂百度和谷歌一通,總的來講有如下幾個方法:
服務器
一、在broker.conf文件添加MQ的IP地址app
[root@test-server rocketmq]# cat conf/broker.conf brokerClusterName = DefaultCluster brokerName = broker-a brokerId = 0 deleteWhen = 04 fileReservedTime = 48 brokerRole = ASYNC_MASTER flushDiskType = ASYNC_FLUSH namesrvAddr=10.1.6.105:9876 brokerIP1=10.1.6.105
試過,沒效果
ide
二、broker啓動時候指定broker.conf配置文件,我原來沒有指定,可是我另一臺也沒有指定就能夠,不懂測試
[root@test-server rocketmq]# nohup sh bin/mqbroker -n localhost:9876 autoCreateTopicEnable=true -c conf/broker.conf &
注意,我原來寫成
ui
[root@test-server rocketmq]# nohup sh bin/mqbroker -n 10.1.6.105:9876 autoCreateTopicEnable=true -c conf/broker.conf &
這樣是不行的spa
三、修改lib/rocketmq-client-4.7.1.jar這個jar包裏面的org/apache/rocketmq/client/impl/producer/DefaultMQProducerImpl.class這個class文件裏面的默認超時參數,我找了很久沒找到那個默認3000的超時時間.net
總結:折騰了一早上加差很少一下午才發現,原來是須要把方法2裏面的broker啓動參數的IP地址寫成localhost:9876,我原來想當來的寫成網卡IP日誌