Skip to content

Commit

Permalink
[ROCKETMQ-175] Consumer may miss messages because of inconsistent sub…
Browse files Browse the repository at this point in the history
…closes apache#92
  • Loading branch information
vsair authored and dongeforever committed May 26, 2017
1 parent 42826c4 commit 8280388
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.apache.rocketmq.common.message.MessageQueue;
import org.apache.rocketmq.common.protocol.heartbeat.ConsumeType;
import org.apache.rocketmq.common.protocol.heartbeat.MessageModel;
import org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData;

public class RebalancePushImpl extends RebalanceImpl {
private final static long UNLOCK_DELAY_TIME_MILLS = Long.parseLong(System.getProperty("rocketmq.client.unlockDelayTimeMills", "20000"));
Expand All @@ -47,6 +48,16 @@ public RebalancePushImpl(String consumerGroup, MessageModel messageModel, Alloca

@Override
public void messageQueueChanged(String topic, Set<MessageQueue> mqAll, Set<MessageQueue> mqDivided) {
/**
* When rebalance result changed, should update subscription's version to notify broker.
* Fix: inconsistency subscription may lead to consumer miss messages.
*/
SubscriptionData subscriptionData = this.subscriptionInner.get(topic);
long newVersion = System.currentTimeMillis();
log.info("{} Rebalance changed, also update version: {}, {}", topic, subscriptionData.getSubVersion(), newVersion);
subscriptionData.setSubVersion(newVersion);
// notify broker
this.getmQClientFactory().sendHeartbeatToAllBrokerWithLock();
}

@Override
Expand Down

0 comments on commit 8280388

Please sign in to comment.