ZhangHLong opened a new issue #2694:
URL: https://github.com/apache/rocketmq/issues/2694


   When I  execute this code,I can see the halfmq on 
RocketMQ-Console,actually,the check was priority set 
‘LocalTransactionState.ROLLBACK_MESSAGE’ ,then the executeLocalTransaction back 
‘LocalTransactionState.COMMIT_MESSAGE’。Strictly speaking,this mq message was 
rollback, but was not the case!!
   
   `public static void main(String[] args) throws MQClientException {
           String topic = "topic_test";
           TransactionMQProducer producer = new 
TransactionMQProducer("test_group");
           producer.setNamesrvAddr("localhost:9876");
           producer.setTransactionListener(new TransactionListener() {
               @Override
               public LocalTransactionState executeLocalTransaction(Message 
msg, Object arg) {
                   System.out.println(" execute local trans: begin ");
                   doSomeThing(65);
                   System.out.println(" execute local trans: over ");
                   return LocalTransactionState.COMMIT_MESSAGE;
               }
   
               @Override
               public LocalTransactionState checkLocalTransaction(MessageExt 
msg) {
                   System.out.println(" check: begin ");
                   doSomeThing(30);
                   System.out.println(" check: over ");
                   return LocalTransactionState.ROLLBACK_MESSAGE;
               }
   
               private void doSomeThing(long second) {
                   try {
                       TimeUnit.SECONDS.sleep(second);
                   } catch (InterruptedException e) {
                       e.printStackTrace();
                   }
               }
           });
           producer.start();
   
           try {
               String msgbody = "mq-half-message";
               Message message = new Message(topic, msgbody.getBytes());
               message.setKeys("mq-key");
               TransactionSendResult send = 
producer.sendMessageInTransaction(message, null);
               System.out.println(send);
           } catch (Exception e) {
               e.printStackTrace();
           }
       }`


----------------------------------------------------------------
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:
[email protected]


Reply via email to