You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2020/04/09 08:09:51 UTC

[GitHub] [rocketmq] lionhuo edited a comment on issue #1923: 异步发送消息,消息丢失问题

lionhuo edited a comment on issue #1923: 异步发送消息,消息丢失问题
URL: https://github.com/apache/rocketmq/issues/1923#issuecomment-611392969
 
 
   this is the 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
   
   it's the producer client log and broker log at that time, then has no response includes success or failed,  
   i can not find this message on the broker also.
   the client sends about more 100 msgs and just losts these two.
   this JVM includes more than one producer which has the same instanceName, it has a problem? 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services