事务在故障转移时回滚,但提交可能已成功
The transaction was rolled back on failover however commit may have been successful
我有一个应用程序使用 jms 将数据发送到 ActiveMQ Artemis 队列。我收到此消息的异常:
The transaction was rolled back on failover however commit may have been successful
这个异常基本上是在告诉我消息可能已经到达队列,也可能没有到达队列,所以我不知道是否需要再次发送消息。在以下情况下处理此类异常的最佳方法是什么:
- 我无法向队列另一端的应用程序发送重复消息。
和
- 我不能跳过消息。
没有比 ActiveMQ Artemis documentation 更好的表述了:
When sending messages from a client to a server, or indeed from a server to another server, if the target server or connection fails sometime after sending the message, but before the sender receives a response that the send (or commit) was processed successfully then the sender cannot know for sure if the message was sent successfully to the address.
If the target server or connection failed after the send was received and processed but before the response was sent back then the message will have been sent to the address successfully, but if the target server or connection failed before the send was received and finished processing then it will not have been sent to the address successfully. From the senders point of view it's not possible to distinguish these two cases.
When the server recovers this leaves the client in a difficult situation. It knows the target server failed, but it does not know if the last message reached its destination ok. If it decides to resend the last message, then that could result in a duplicate message being sent to the address. If each message was an order or a trade then this could result in the order being fulfilled twice or the trade being double booked. This is clearly not a desirable situation.
Sending the message(s) in a transaction does not help out either. If the server or connection fails while the transaction commit is being processed it is also indeterminate whether the transaction was successfully committed or not!
To solve these issues Apache ActiveMQ Artemis provides automatic duplicate messages detection for messages sent to addresses.
在 ActiveMQ Artemis documentation 中查看有关如何配置和使用重复检测的更多详细信息。
我有一个应用程序使用 jms 将数据发送到 ActiveMQ Artemis 队列。我收到此消息的异常:
The transaction was rolled back on failover however commit may have been successful
这个异常基本上是在告诉我消息可能已经到达队列,也可能没有到达队列,所以我不知道是否需要再次发送消息。在以下情况下处理此类异常的最佳方法是什么:
- 我无法向队列另一端的应用程序发送重复消息。
和
- 我不能跳过消息。
没有比 ActiveMQ Artemis documentation 更好的表述了:
When sending messages from a client to a server, or indeed from a server to another server, if the target server or connection fails sometime after sending the message, but before the sender receives a response that the send (or commit) was processed successfully then the sender cannot know for sure if the message was sent successfully to the address.
If the target server or connection failed after the send was received and processed but before the response was sent back then the message will have been sent to the address successfully, but if the target server or connection failed before the send was received and finished processing then it will not have been sent to the address successfully. From the senders point of view it's not possible to distinguish these two cases.
When the server recovers this leaves the client in a difficult situation. It knows the target server failed, but it does not know if the last message reached its destination ok. If it decides to resend the last message, then that could result in a duplicate message being sent to the address. If each message was an order or a trade then this could result in the order being fulfilled twice or the trade being double booked. This is clearly not a desirable situation.
Sending the message(s) in a transaction does not help out either. If the server or connection fails while the transaction commit is being processed it is also indeterminate whether the transaction was successfully committed or not!
To solve these issues Apache ActiveMQ Artemis provides automatic duplicate messages detection for messages sent to addresses.
在 ActiveMQ Artemis documentation 中查看有关如何配置和使用重复检测的更多详细信息。