ActiveMQ producer 提交事务时突然宕机,会发生什么

producer 在提交事务时,发生宕机,commit 的命令没有发送到 broker,这时会发生什么?

ActiveMQ 开启事务发送消息的步骤:

session.getTransactionContext().begin();

producer.send(message);

session.getTransactionContext().commit();

在第三步加断点,然后关闭 producer 进程,模仿宕机。

broker 感知到 producer 的连接关闭后,会触发删除连接操作,回滚该连接下没有提交的事务。

猜你喜欢

转载自www.cnblogs.com/allenwas3/p/9133133.html