RocketMQ异常(一)

RocketMQ异常(一)

org.apache.rocketmq.client.exception.MQClientException: No route info for this topic, TopicTestjjj

  • 根据官方文档配置的MQ,并且复制的示例代码,但是运行就报错了。
  • 参考了很多博客得出以下三种结论

    1. Broker没有开启自动创建主题
    2. Broker 没有正确连接到 Name Server
    3. Producer 没有正确链接到Name Server
  • 第一步 查看启动方式是否正确
    nohup sh bin/mqbroker -n localhost:9876 autoCreateTopicEnable=true &
    官方给的是
    nohup sh bin/mqbroker -n localhost:9876 &
    然后执行
    sh bin/mqbroker -m

    chenchenghao@cch:/soft/apache-rocketmq$ sh bin/mqbroker -m
    2018-09-03 23:10:27 INFO main - namesrvAddr=
    2018-09-03 23:10:27 INFO main - brokerIP1=192.168.0.111
    2018-09-03 23:10:27 INFO main - brokerName=cch
    2018-09-03 23:10:27 INFO main - brokerClusterName=DefaultCluster
    2018-09-03 23:10:27 INFO main - brokerId=0
    2018-09-03 23:10:27 INFO main - autoCreateTopicEnable=true
    2018-09-03 23:10:27 INFO main - autoCreateSubscriptionGroup=true
    2018-09-03 23:10:27 INFO main - rejectTransactionMessage=false
    2018-09-03 23:10:27 INFO main - fetchNamesrvAddrByAddressServer=false
    2018-09-03 23:10:27 INFO main - transactionTimeOut=3000
    2018-09-03 23:10:27 INFO main - transactionCheckMax=5
    2018-09-03 23:10:27 INFO main - transactionCheckInterval=60000
    2018-09-03 23:10:27 INFO main - storePathRootDir=/home/chenchenghao/store
    2018-09-03 23:10:27 INFO main - storePathCommitLog=/home/chenchenghao/store/commitlog
    2018-09-03 23:10:27 INFO main - flushIntervalCommitLog=500
    2018-09-03 23:10:27 INFO main - commitIntervalCommitLog=200
    2018-09-03 23:10:27 INFO main - flushCommitLogTimed=false
    2018-09-03 23:10:27 INFO main - deleteWhen=04
    2018-09-03 23:10:27 INFO main - fileReservedTime=72
    2018-09-03 23:10:27 INFO main - maxTransferBytesOnMessageInMemory=262144
    2018-09-03 23:10:27 INFO main - maxTransferCountOnMessageInMemory=32
    2018-09-03 23:10:27 INFO main - maxTransferBytesOnMessageInDisk=65536
    2018-09-03 23:10:27 INFO main - maxTransferCountOnMessageInDisk=8
    2018-09-03 23:10:27 INFO main - accessMessageInMemoryMaxRatio=40
    2018-09-03 23:10:27 INFO main - messageIndexEnable=true
    2018-09-03 23:10:27 INFO main - messageIndexSafe=false
    2018-09-03 23:10:27 INFO main - haMasterAddress=
    2018-09-03 23:10:27 INFO main - brokerRole=ASYNC_MASTER
    2018-09-03 23:10:27 INFO main - flushDiskType=ASYNC_FLUSH
    2018-09-03 23:10:27 INFO main - cleanFileForciblyEnable=true
    2018-09-03 23:10:27 INFO main - transientStorePoolEnable=false
    chenchenghao@cch:/soft/apache-rocketmq$ 
    
  • 第二步 查看Broker 有没有正确连接到 Name Server
    Broker启动后,项目启动成功,看到add borker success 就是对的

  • 第三步 查看是否有防火墙
    博主这里并没有开启防火墙 但是依然在报这个错,后来我就怀疑官方给的demo代码有问题
    最终发现没有配置NamesrvAddr。
    这个真心坑!!!
    修改代码新增producer.setNamesrvAddr(“localhost:9876”);

注意本文主要参考了以下博客https://blog.csdn.net/wangmx1993328/article/details/81588217

你可能感兴趣的:(RocketMQ)