开发者社区 > 云原生 > 正文

异步发送消息,消息丢失问题

版本: 4.6.1 OS: Centos 部署方式:一主一从

问题描述: 采用DefaultMQProducer的异步发送方式,client端执行完send后,broker端无该消息的任何信息,本地也无任何响应回调,当时broker服务器上的cpu和内存也正常,查看了client,remoting,broker的日志也没有该消息的任何踪迹。

请问一下,这种情况的可能原因是什么?遇到这种问题从哪里入手查找? 谢谢

producer code

@PostConstruct public void init(){ producer = new DefaultMQProducer("PRODUCER_GROUP"); producer.setNamespace(namesrvAddr); producer.setRetryTimesWhenSendAsyncFailed(3);

    try {
        producer.start();
    } catch (MQClientException e) {
        logger.error("========>  errMsg:{}", e.getMessage(), e);
    }

    logger.info("--------> producer group:PRODUCER_GROUP");
}

public void sendJobInfo(TaServer taServer, JobInfoVO jobInfoVO, short sendType){ try{ logger.info("--------> send job info, ta:{}, job id:{}, send type:{}", taServer.getName(), jobInfoVO.getJob().getId(), sendType);

        JSONObject msgObj = new JSONObject();
        msgObj.put("jobInfo", jobInfoVO);
        msgObj.put("sendType", sendType);

        String msgObjJson = JSONObject.toJSONString(msgObj);

        Message msg = new Message("REQUEST_TOPIC" /* Topic */,
                taServer.getFqdn()/*Tag*/,
                new StringBuilder("job-req-").append(jobInfoVO.getJob().getId()).append("-").append(sendType).toString(), /*key e.g. job-req-1000-2*/
                msgObjJson.getBytes(RemotingHelper.DEFAULT_CHARSET) /* Message body */
        );


        producer.send(msg, new SendCallback() {
            @Override
            public void onSuccess(SendResult sendResult) {
                logger.info("-------->send job info success:{}", sendResult);
            }

            @Override
            public void onException(Throwable throwable) {
                logger.info("-------->send job info error:{}", throwable.getMessage());
            }
        });


    } catch (Exception e) {
        logger.error("========> send job info failed, errMsg:{}", e.getMessage(), e);
    }

}

[producer log] 2020-04-03 05:14:20,529 [scheduler-7] INFO --------> send job info, ta:xxxxxx, job id:267374, send type:2 2020-04-03 05:14:20,620 [scheduler-7] INFO - --------> send job info, ta:xxxxxx, job id:267375, send type:2

[broker log] 2020-04-03 05:14:06 INFO brokerOutApi_thread_3 - register broker[0]to name server xxxxxx:9876 OK 2020-04-03 05:14:12 INFO brokerOutApi_thread_1 - register broker[1]to name server xxxxxx:9876 OK 2020-04-03 05:14:15 INFO BrokerControllerScheduledThread1 - Update slave consumer offset from master, xxxxxx:10911 2020-04-03 05:14:15 INFO BrokerControllerScheduledThread1 - Update slave delay offset from master, xxxxxx:10911 2020-04-03 05:14:25 INFO BrokerControllerScheduledThread1 - Update slave consumer offset from master, xxxxxx:10911 2020-04-03 05:14:25 INFO BrokerControllerScheduledThread1 - Update slave delay offset from master, xxxxxx:10911 2020-04-03 05:14:35 INFO BrokerControllerScheduledThread1 - Update slave consumer offset from master, xxxxxx:10911 2020-04-03 05:14:35 INFO BrokerControllerScheduledThread1 - Update slave delay offset from master, xxxxxx:10911 2020-04-03 05:14:36 INFO BrokerControllerScheduledThread1 - dispatch behind commit log 0 bytes 2020-04-03 05:14:36 INFO BrokerControllerScheduledThread1 - Slave fall behind master: 0 bytes 2020-04-03 05:14:36 INFO brokerOutApi_thread_4 - register broker[0]to name server xxxxxx:9876 OK 2020-04-03 05:14:42 INFO BrokerControllerScheduledThread1 - dispatch behind commit log 0 bytes 2020-04-03 05:14:42 INFO brokerOutApi_thread_2 - register broker[1]to name server xxxxxx:9876 OK

当时是生产者客户端日志和经纪人日志,然后没有响应,包括成功或失败, 我在经纪人那里也找不到这条消息。 客户端发送了大约100多条消息,但只丢失了这两条。 这个JVM包括多个具有相同instanceName的生产者,它有问题吗?

原提问者GitHub用户lionhuo

展开
收起
芬奇福贵 2023-05-26 11:46:03 159 0
1 条回答
写回答
取消 提交回答
  • producer.setNamespace(namesrvAddr); 这个参数配置错了,你想配置的可能是 nameserver 地址

    原回答者GitHub用户rushsky518

    2023-05-26 17:38:07
    赞同 展开评论 打赏
问答分类:
问答地址:

阿里云拥有国内全面的云原生产品技术以及大规模的云原生应用实践,通过全面容器化、核心技术互联网化、应用 Serverless 化三大范式,助力制造业企业高效上云,实现系统稳定、应用敏捷智能。拥抱云原生,让创新无处不在。

热门讨论

热门文章

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载