SuperIllidan commented on issue #2265:
URL: https://github.com/apache/rocketmq/issues/2265#issuecomment-679773594
> can you show all your code and message send result
It's quite simple spring boot project.
Here is the producer:
@Slf4j
@Component
public class OrderTransactionMsgProducer implements CommandLineRunner {
private TransactionMQProducer producer;
@Override
public void run(String... args) throws Exception {
producer = new
TransactionMQProducer("order_trans_msg_producer_group");
producer.setNamesrvAddr("dev-rq01-a.mq.01zhuanche.com:9876");
producer.setTransactionListener(new TransactionListener() {
@Override
public LocalTransactionState executeLocalTransaction(Message
msg, Object arg) {
// try {
// log.info("Execute my transaction. for some reason
...");
// TimeUnit.SECONDS.sleep(60);
// return LocalTransactionState.COMMIT_MESSAGE;
// } catch (InterruptedException e) {
// Thread.currentThread().interrupt();
// }
// return LocalTransactionState.UNKNOW;
return LocalTransactionState.UNKNOW;
}
@Override
public LocalTransactionState checkLocalTransaction(MessageExt
msg) {
log.info("Broker check my transaction state");
return LocalTransactionState.COMMIT_MESSAGE;
}
});
producer.start();
}
public TransactionSendResult sendOrderTransactionMsg(String content) {
Message msg = new Message("order_transaction_topic",
content.getBytes());
try {
TransactionSendResult result =
producer.sendMessageInTransaction(msg, "myArg");
log.info("sending result:{}", result);
} catch (MQClientException e) {
log.error("exception", e);
}
return null;
}
}
I triggered the producer to send a msg and executeLocalTransaction would be
invoked. But checkLocalTransaction wouldn't.(By the way, there is spelling
mistake: LocalTransactionState.UNKNOW)
----------------------------------------------------------------
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]