Skip to content

Commit

Permalink
[ISSUE 99 & ISSUE 107] Fix the message was consumed twice because of …
Browse files Browse the repository at this point in the history
…the same instanceName
  • Loading branch information
RongtongJin authored and ShannonDing committed Sep 10, 2019
1 parent 0834f86 commit 908ea48
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* RocketMQMessageListener
*/
@Service
@RocketMQMessageListener(nameServer = "${demo.rocketmq.myNameServer}", topic = "${demo.rocketmq.topic}", consumerGroup = "string_consumer")
@RocketMQMessageListener(nameServer = "${demo.rocketmq.myNameServer}", topic = "${demo.rocketmq.topic}", consumerGroup = "string_consumer_newns")
public class StringConsumerNewNS implements RocketMQListener<String> {
@Override
public void onMessage(String message) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,6 @@ private void initRocketMQPushConsumer() throws MQClientException {
consumer.setConsumeThreadMin(consumeThreadMax);
}
consumer.setConsumeTimeout(consumeTimeout);
consumer.setInstanceName(this.name);

switch (messageModel) {
case BROADCASTING:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.producer.LocalTransactionState;
import org.apache.rocketmq.client.producer.TransactionListener;
import org.apache.rocketmq.common.UtilAll;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.common.message.MessageConst;
import org.apache.rocketmq.common.message.MessageExt;
Expand Down Expand Up @@ -211,7 +212,8 @@ public static String getInstanceName(RPCHook rpcHook, String identify) {
SessionCredentials sessionCredentials = ((AclClientRPCHook) rpcHook).getSessionCredentials();
instanceName.append(sessionCredentials.getAccessKey())
.append(separator).append(sessionCredentials.getSecretKey())
.append(separator).append(identify);
.append(separator).append(identify)
.append(separator).append(UtilAll.getPid());
return instanceName.toString();
}
}

0 comments on commit 908ea48

Please sign in to comment.