This is an automated email from the ASF dual-hosted git repository.
jianbin pushed a commit to branch 2.x
in repository https://gitbox.apache.org/repos/asf/incubator-seata.git
The following commit(s) were added to refs/heads/2.x by this push:
new 93d9247066 optimize: disallow messages with delay time levels in Seata
transactions and add a corresponding test. (#7860)
93d9247066 is described below
commit 93d9247066ac083a28fbd374d7326fd8a8428a86
Author: aias00 <[email protected]>
AuthorDate: Tue Dec 16 09:27:02 2025 +0800
optimize: disallow messages with delay time levels in Seata transactions
and add a corresponding test. (#7860)
---
changes/en-us/2.x.md | 2 ++
changes/zh-cn/2.x.md | 2 ++
.../seata/integration/rocketmq/SeataMQProducer.java | 2 +-
.../seata/integration/rocketmq/SeataMQProducerTest.java | 15 +++++++++++++++
4 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/changes/en-us/2.x.md b/changes/en-us/2.x.md
index 76e030f3ec..48e6d029ce 100644
--- a/changes/en-us/2.x.md
+++ b/changes/en-us/2.x.md
@@ -56,6 +56,7 @@ Add changes here for all PR submitted to the 2.x branch.
- [[#7796](https://github.com/apache/incubator-seata/pull/7796)] fix the NPE
on ConsulConfigurationTest method
- [[#7839](https://github.com/apache/incubator-seata/pull/7839)] resolve
TransactionAutoConfiguration compatibility with Spring Boot 4.x
- [[#7855](https://github.com/apache/incubator-seata/pull/7855)] fix comma
missing in package.json/min-document
+- [[#7860](https://github.com/apache/incubator-seata/pull/7860)] Fix the issue
where delayed messages in RocketMQ transactions were silently ignored, now
explicitly throwing an exception
### optimize:
@@ -188,6 +189,7 @@ Thanks to these contributors for their code commits. Please
report an unintended
- [xiaoxiangyeyu0](https://github.com/xiaoxiangyeyu0)
- [jsbxyyx](https://github.com/jsbxyyx)
- [xingfudeshi](https://github.com/xingfudeshi)
+- [aias00](https://github.com/aias00)
Also, we receive many valuable issues, questions and advices from our
community. Thanks for you all.
diff --git a/changes/zh-cn/2.x.md b/changes/zh-cn/2.x.md
index d566d506c3..4b4d087424 100644
--- a/changes/zh-cn/2.x.md
+++ b/changes/zh-cn/2.x.md
@@ -56,6 +56,7 @@
- [[#7796](https://github.com/apache/incubator-seata/pull/7796)] 修复 Consul
监听器空值 NPE 问题
- [[#7839](https://github.com/apache/incubator-seata/pull/7839)]
解决TransactionAutoConfiguration与Spring Boot 4.x的兼容性问题
- [[#7855](https://github.com/apache/incubator-seata/pull/7855)]
修复package.json中min-document的逗号缺失
+- [[#7860](https://github.com/apache/incubator-seata/pull/7860)] 修复 RocketMQ
事务中延迟消息静默失效的问题,改为显式抛出异常
### optimize:
@@ -186,6 +187,7 @@
- [xiaoxiangyeyu0](https://github.com/xiaoxiangyeyu0)
- [jsbxyyx](https://github.com/jsbxyyx)
- [xingfudeshi](https://github.com/xingfudeshi)
+- [aias00](https://github.com/aias00)
同时,我们收到了社区反馈的很多有价值的issue和建议,非常感谢大家。
diff --git
a/extensions/messaging/seata-rocketmq/src/main/java/org/apache/seata/integration/rocketmq/SeataMQProducer.java
b/extensions/messaging/seata-rocketmq/src/main/java/org/apache/seata/integration/rocketmq/SeataMQProducer.java
index 9c4d1538e5..6e352ae480 100644
---
a/extensions/messaging/seata-rocketmq/src/main/java/org/apache/seata/integration/rocketmq/SeataMQProducer.java
+++
b/extensions/messaging/seata-rocketmq/src/main/java/org/apache/seata/integration/rocketmq/SeataMQProducer.java
@@ -115,7 +115,7 @@ public class SeataMQProducer extends TransactionMQProducer {
throws MQClientException {
msg.setTopic(withNamespace(msg.getTopic()));
if (msg.getDelayTimeLevel() != 0) {
- MessageAccessor.clearProperty(msg,
MessageConst.PROPERTY_DELAY_TIME_LEVEL);
+ throw new MQClientException("Message delay time level is not
supported in Seata transaction", null);
}
Validators.checkMessage(msg, this);
diff --git
a/extensions/messaging/seata-rocketmq/src/test/java/org/apache/seata/integration/rocketmq/SeataMQProducerTest.java
b/extensions/messaging/seata-rocketmq/src/test/java/org/apache/seata/integration/rocketmq/SeataMQProducerTest.java
index 53de04ff4e..d8b5222cbf 100644
---
a/extensions/messaging/seata-rocketmq/src/test/java/org/apache/seata/integration/rocketmq/SeataMQProducerTest.java
+++
b/extensions/messaging/seata-rocketmq/src/test/java/org/apache/seata/integration/rocketmq/SeataMQProducerTest.java
@@ -42,6 +42,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyLong;
@@ -361,6 +362,20 @@ public class SeataMQProducerTest {
verify(seataMQProducer).superSend(msg, timeout);
}
+ @Test
+ void testDoSendMessageInTransactionWithDelayLevel() {
+ Message msg = new Message("testTopic", "testBody".getBytes());
+ msg.setDelayTimeLevel(1);
+ long timeout = 3000L;
+ String xid = "testXid";
+ long branchId = 123L;
+
+ MQClientException exception = assertThrows(
+ MQClientException.class, () ->
seataMQProducer.doSendMessageInTransaction(msg, timeout, xid, branchId));
+ // RocketMQ client might append FAQ url to the exception message
+ assertTrue(exception.getMessage().startsWith("Message delay time level
is not supported in Seata transaction"));
+ }
+
@Test
void getTransactionListenerShouldReturnNonNullTransactionListener() {
TransactionListener transactionListener =
producer.getTransactionListener();
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]