The TransactionMQProducer When check set state ROLLBACK_MESSAGE ,the execute should not COMMIT_MESSAGE again!
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();
}
}`

The transaction message review first executes executeLocalTransaction, then there is no commit, and then checkLocalTransaction will be executed all the time
The transaction message review first executes executeLocalTransaction, then there is no commit, and then checkLocalTransaction will be executed all the time
The half message was send ,when executes executeLocalTransaction blocked,the checkLocalTransaction begin to execute and set the half message would be rollback,how can executeLocalTransaction change the state? I can not understand it。
It's like a variable happens ABA problems;
when the method executeLocalTransaction return COMMIT, method checkLocalTransaction will be not executed. when the method executeLocalTransaction return UNKNOW, method checkLocalTransaction will be executed until the result is returned。 when the method executeLocalTransaction blocking, from the perspective of Broker, the status of this Half status message is unknown. Therefore, the Broker will periodically ask the sender to check the Half status message and report its final status.
The problem still exists
version:4.7.1 config:transientStorePoolEnable=false
This issue is stale because it has been open for 365 days with no activity. It will be closed in 3 days if no further activity occurs.
This issue was closed because it has been inactive for 3 days since being marked as stale.