rocketmq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jinrongt...@apache.org
Subject [rocketmq-spring] branch master updated: [ISSUE #339] Fix consumer do not consume message with the same instance name
Date Wed, 17 Mar 2021 14:11:14 GMT
This is an automated email from the ASF dual-hosted git repository.

jinrongtong pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-spring.git


The following commit(s) were added to refs/heads/master by this push:
     new 89946bb  [ISSUE #339] Fix consumer do not consume message with the same instance
name
89946bb is described below

commit 89946bb3459d7837446ef48dd07b15ea24777c3a
Author: 张旭 <maixiaohai00@gmail.com>
AuthorDate: Wed Mar 17 22:10:51 2021 +0800

    [ISSUE #339] Fix consumer do not consume message with the same instance name
    
    Co-authored-by: zhangxu16 <zhangxu16@xiaomi.com>
---
 .../src/main/java/org/apache/rocketmq/spring/support/RocketMQUtil.java | 3 ++-
 .../test/java/org/apache/rocketmq/spring/support/RocketMQUtilTest.java | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/support/RocketMQUtil.java
b/rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/support/RocketMQUtil.java
index a891fa7..381d936 100644
--- a/rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/support/RocketMQUtil.java
+++ b/rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/support/RocketMQUtil.java
@@ -287,7 +287,8 @@ public class RocketMQUtil {
         char separator = '@';
         StringBuilder instanceName = new StringBuilder();
         instanceName.append(identify)
-                .append(separator).append(UtilAll.getPid());
+                .append(separator).append(UtilAll.getPid())
+                .append(separator).append(System.nanoTime());
         return instanceName.toString();
     }
 
diff --git a/rocketmq-spring-boot/src/test/java/org/apache/rocketmq/spring/support/RocketMQUtilTest.java
b/rocketmq-spring-boot/src/test/java/org/apache/rocketmq/spring/support/RocketMQUtilTest.java
index e558483..30b8026 100644
--- a/rocketmq-spring-boot/src/test/java/org/apache/rocketmq/spring/support/RocketMQUtilTest.java
+++ b/rocketmq-spring-boot/src/test/java/org/apache/rocketmq/spring/support/RocketMQUtilTest.java
@@ -135,6 +135,6 @@ public class RocketMQUtilTest {
     public void testGetInstanceName() {
         String nameServer = "127.0.0.1:9876";
         String expected = "127.0.0.1:9876@";
-        assertEquals(expected + UtilAll.getPid(), RocketMQUtil.getInstanceName(nameServer));
+        assertTrue(RocketMQUtil.getInstanceName(nameServer).startsWith(expected + UtilAll.getPid()));
     }
 }
\ No newline at end of file


Mime
View raw message