13735485496 opened a new issue, #8702: URL: https://github.com/apache/rocketmq/issues/8702
### Before Creating the Bug Report - [X] I found a bug, not just asking a question, which should be created in [GitHub Discussions](https://github.com/apache/rocketmq/discussions). - [X] I have searched the [GitHub Issues](https://github.com/apache/rocketmq/issues) and [GitHub Discussions](https://github.com/apache/rocketmq/discussions) of this repository and believe that this is not a duplicate. - [X] I have confirmed that this bug belongs to the current repository, not other repositories of RocketMQ. ### Runtime platform environment CentOS Linux release 7.9.2009 (Core) ### RocketMQ version <dependency> <groupId>org.apache.rocketmq</groupId> <artifactId>rocketmq-client</artifactId> <version>4.9.4</version> </dependency> ### JDK Version java version "1.8.0_381" Java(TM) SE Runtime Environment (build 1.8.0_381-b09) Java HotSpot(TM) Client VM (build 25.381-b09, mixed mode, sharing) ### Describe the Bug 第一个问题:当消费者获取消息的ORIGIN_MESSAGE_ID属性,这个属性在第一次就消费成功的时候,是不存在的,服务端处理的时候,捕获到了异常,就暴力的把消费的status设置为null,进而转入RECONSUME_LATER,这个会导致首次失败 第二个问题:当消费者获取消息不存在的属性,会有空指针异常,导致status设置为null,进而转入RECONSUME_LATER,这个会一直失败,直到进入死信队列 ### Steps to Reproduce consumer.registerMessageListener(new MessageListenerConcurrently() { @Override public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs, ConsumeConcurrentlyContext context) { for (MessageExt msg : msgs){ try { //格式化输出时间 LocalDateTime currentTime = LocalDateTime.now(); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); String currentTimeString = currentTime.format(formatter); //接收到消息就打印 System.out.println("消费者接收到消息了!!!" +", 当前时间:" + currentTimeString +"消费者线程:" + Thread.currentThread().getName() +", 消息的topic:" + new String(msg.getTopic()) +", 队列id:" + msg.getQueueId() +", body:" + new String(msg.getBody(), RemotingHelper.DEFAULT_CHARSET) +", 消息id:" + new String(msg.getMsgId()) +", 当前延迟级别:" +new String(String.valueOf(msg.getDelayTimeLevel())) +", 消息的重试次数:" +new String(String.valueOf(msg.getReconsumeTimes())) //第一个问题:当消费者获取消息的ORIGIN_MESSAGE_ID属性,这个属性在第一次就消费成功的时候,是不存在的,服务端处理的时候,捕获到了异常,就暴力的把消费的status设置为null,进而转入RECONSUME_LATER,这个会导致首次失败,但客户端感知不到异常 //+", 消息的原始messageid:" // +new String(msg.getProperty("ORIGIN_MESSAGE_ID")) //第二个问题:当消费者获取消息不存在的属性,会有空指针异常,导致status设置为null,进而转入RECONSUME_LATER,这个会一直失败,直到进入死信队列,但是客户端无法感知异常 //+", 尝试查询某个不存在的属性:" // +new String(msg.getProperty("111")) +", 消息的各项属性:" +new String(String.valueOf(msg.getProperties())) +", 消息的CommitLogOffset:" +new String(String.valueOf(msg.getCommitLogOffset())) +", 消息的QueueOffset:" +new String(String.valueOf(msg.getQueueOffset())) ); //如果是第1条消息,才消费成功,第0条消息消费失败,第2条消息被sql过滤掉 if(new String(msg.getBody(), "UTF-8").equals("这是第1条消息")){ System.out.println("消息id:" +new String(msg.getMsgId())+"消费成功!"); return ConsumeConcurrentlyStatus.CONSUME_SUCCESS; } else{ if(new String(String.valueOf(msg.getReconsumeTimes())).equals("2")){ System.out.println("消息id:" +new String(msg.getMsgId())+"消费失败次数达到2次了"); } System.out.println("消息id:" +new String(msg.getMsgId())+"消费失败!"); return ConsumeConcurrentlyStatus.RECONSUME_LATER; } } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } return ConsumeConcurrentlyStatus.RECONSUME_LATER; } }); ### What Did You Expect to See? 将异常返还给客户端 ### What Did You See Instead? 客户端没有收到任何异常结果 ### Additional Context debug过程 <img width="1920" alt="1" src="https://github.com/user-attachments/assets/d6a04b5f-4498-47d2-90b6-433d0fb260d9"> <img width="1920" alt="2" src="https://github.com/user-attachments/assets/c064e7c1-18a2-4343-8671-5bd5694caefe"> <img width="1920" alt="3" src="https://github.com/user-attachments/assets/c5445679-aa4e-4328-a057-843dd699510f"> <img width="1920" alt="4" src="https://github.com/user-attachments/assets/cc42652c-cb7e-4467-b22f-d97d854800a6"> <img width="1920" alt="5" src="https://github.com/user-attachments/assets/c6c9f8f6-db09-42f7-a66c-66e68cf3d7a6"> <img width="1920" alt="6" src="https://github.com/user-attachments/assets/63497877-5fe0-4c58-9596-33dd510bbd60"> -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
