排查1:Broker 禁止自动创建 Topic,且用户没有通过手工方式创建 Topic

2023-05-12 20:29:58 浏览数 (2)

背景

系统订单创建成功之后需要发送订单创建成功的消息,但是今天突然遇到了如下的报错

代码语言:javascript复制
org.apache.rocketmq.client.exception.MQClientException: No route info of this topic, TopicTest
See http://rocketmq.apache.org/docs/faq/ for further details.
    at org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl.sendDefaultImpl(DefaultMQProducerImpl.java:610)
    at org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl.send(DefaultMQProducerImpl.java:1223)
    at org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl.send(DefaultMQProducerImpl.java:1173)
    at org.apache.rocketmq.client.producer.DefaultMQProducer.send(DefaultMQProducer.java:214)

探究

出现上面的错误,主要有三种情况

一:Topic不存在,即没有创建出来次Topic(我们项目均为手动创建),或者Broker模块不支持自动创建topic。

二:Broker模块没有正确连接到Name Server

三:Producer没有正确连接到Name Server 

办法

排查1:Broker 禁止自动创建 Topic,且用户没有通过手工方式创建 Topic

可以在 Rocket_HOME/distribution/target/apache-rocketmq 下执行 " sh bin/mqbroker -m " 来查看 broker 的配置参数 如下所示,autoCreateTopicEnable=true 证明是没有问题的

代码语言:javascript复制
[root@localhost apache-rocketmq]# sh ./bin/mqbroker -m
2018-08-12 01:27:28 INFO main - namesrvAddr=
2018-08-12 01:27:28 INFO main - brokerIP1=192.168.58.129
2018-08-12 01:27:28 INFO main - brokerName=localhost.localdomain
2018-08-12 01:27:28 INFO main - brokerClusterName=DefaultCluster
2018-08-12 01:27:28 INFO main - brokerId=0
2018-08-12 01:27:28 INFO main - autoCreateTopicEnable=true
2018-08-12 01:27:28 INFO main - autoCreateSubscriptionGroup=true
2018-08-12 01:27:28 INFO main - rejectTransactionMessage=false
2018-08-12 01:27:28 INFO main - fetchNamesrvAddrByAddressServer=false
2018-08-12 01:27:28 INFO main - transactionTimeOut=3000
2018-08-12 01:27:28 INFO main - transactionCheckMax=5
2018-08-12 01:27:28 INFO main - transactionCheckInterval=60000
2018-08-12 01:27:28 INFO main - storePathRootDir=/root/store
2018-08-12 01:27:28 INFO main - storePathCommitLog=/root/store/commitlog
2018-08-12 01:27:28 INFO main - flushIntervalCommitLog=500
2018-08-12 01:27:28 INFO main - commitIntervalCommitLog=200
2018-08-12 01:27:28 INFO main - flushCommitLogTimed=false
2018-08-12 01:27:28 INFO main - deleteWhen=04
2018-08-12 01:27:28 INFO main - fileReservedTime=72
2018-08-12 01:27:28 INFO main - maxTransferBytesOnMessageInMemory=262144
2018-08-12 01:27:28 INFO main - maxTransferCountOnMessageInMemory=32
2018-08-12 01:27:28 INFO main - maxTransferBytesOnMessageInDisk=65536
2018-08-12 01:27:28 INFO main - maxTransferCountOnMessageInDisk=8
2018-08-12 01:27:28 INFO main - accessMessageInMemoryMaxRatio=40
2018-08-12 01:27:28 INFO main - messageIndexEnable=true
2018-08-12 01:27:28 INFO main - messageIndexSafe=false
2018-08-12 01:27:28 INFO main - haMasterAddress=
2018-08-12 01:27:28 INFO main - brokerRole=ASYNC_MASTER
2018-08-12 01:27:28 INFO main - flushDiskType=ASYNC_FLUSH
2018-08-12 01:27:28 INFO main - cleanFileForciblyEnable=true
2018-08-12 01:27:28 INFO main - transientStorePoolEnable=false
[root@localhost apache-rocketmq]#

排查2:Broker 没有正确连接到 Name Server

如下所示,启动 broker 的时候,只要看到了 The broker[localhost.localdomain, 192.168.58.129:10911] boot success. serializeType=JSON and name server is localhost:9876 字样就说明是成功的

代码语言:javascript复制
[root@localhost apache-rocketmq]# nohup sh bin/mqbroker -n localhost:9876 &
[2] 3256
[1] 退出 143 nohup sh bin/mqbroker -n localhost:9876
[root@localhost apache-rocketmq]# nohup: 忽略输入并把输出追加到"nohup.out"
tail -f ~/logs/rocketmqlogs/broker.log
2018-08-11 23:48:26 INFO main - load exist subscription group, SubscriptionGroupConfig [groupName=CID_ONSAPI_OWNER, consumeEnable=true, consumeFromMinEnable=true, consumeBroadcastEnable=true, retryQueueNums=1, retryMaxTimes=16, brokerId=
2018-08-11 23:48:31 WARN main - Load default discard message hook service: DefaultTransactionalMessageCheckListener
2018-08-11 23:48:31 INFO FileWatchService - FileWatchService service started
2018-08-11 23:48:31 INFO PullRequestHoldService - PullRequestHoldService service started
2018-08-11 23:48:31 INFO brokerOutApi_thread_1 - register broker to name server localhost:9876 OK
2018-08-11 23:48:31 INFO main - Start transaction service!
2018-08-11 23:48:31 INFO main - The broker[localhost.localdomain, 192.168.58.129:10911] boot success. serializeType=JSON and name server is localhost:9876
2018-08-11 23:48:41 INFO BrokerControllerScheduledThread1 - dispatch behind commit log 0 bytes
2018-08-11 23:48:41 INFO BrokerControllerScheduledThread1 - Slave fall behind master: 906412 bytes
2018-08-11 23:48:41 INFO brokerOutApi_thread_2 - register broker to name server localhost:9876 OK

排查3:Producer 没有正确连接到 Name Server

如果按前两步检查没有问题,但启动还是报错,那就只剩下第三种情况了,最大可能是发送者和mq服务器之间的网络或端口不通,可以使用ping或者telnet确定问题。如果ping或者telnet连接不通,则说明producer无法连接到nameserver,很可能是防火墙的原因 ,需要联系运维工程师开通网络或端口权限。

0 人点赞