Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE #8674] fix():The correct consumption pattern when the heartbeat is reported #8675

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
private ConsumeMessageService consumeMessagePopService;
private long queueFlowControlTimes = 0;
private long queueMaxSpanFlowControlTimes = 0;
private boolean existPop = false;

//10s 30s 1m 2m 3m 4m 5m 6m 7m 8m 9m 10m 20m 30m 1h 2h
private final int[] popDelayLevel = new int[] {10, 30, 60, 120, 180, 240, 300, 360, 420, 480, 540, 600, 1200, 1800, 3600, 7200};
Expand Down Expand Up @@ -1370,6 +1371,9 @@ public MessageModel messageModel() {

@Override
public ConsumeType consumeType() {
if (!defaultMQPushConsumer.isClientRebalance() && isExistPop()) {
return ConsumeType.CONSUME_POP;
}
return ConsumeType.CONSUME_PASSIVELY;
}

Expand Down Expand Up @@ -1595,4 +1599,12 @@ public MessageQueueListener getMessageQueueListener() {
}
return defaultMQPushConsumer.getMessageQueueListener();
}

public void setExistPop(boolean existPop) {
this.existPop = existPop;
}

public boolean isExistPop() {
return existPop;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ private boolean rebalanceByTopic(final String topic, final boolean isOrder) {
private boolean getRebalanceResultFromBroker(final String topic, final boolean isOrder) {
String strategyName = this.allocateMessageQueueStrategy.getName();
Set<MessageQueueAssignment> messageQueueAssignments;
boolean existPop = false;
try {
messageQueueAssignments = this.mQClientFactory.queryAssignment(topic, consumerGroup,
strategyName, messageModel, QUERY_ASSIGNMENT_TIMEOUT);
Expand All @@ -401,7 +402,15 @@ private boolean getRebalanceResultFromBroker(final String topic, final boolean i
if (messageQueueAssignment.getMessageQueue() != null) {
mqSet.add(messageQueueAssignment.getMessageQueue());
}
if (!existPop && ConsumeType.CONSUME_POP.getTypeCN().equals(messageQueueAssignment.getMode().getName())) {
existPop = true;
}
}
if (this.consumeType() == ConsumeType.CONSUME_PASSIVELY) {
RebalancePushImpl rebalancePush = (RebalancePushImpl) this;
rebalancePush.getDefaultMQPushConsumerImpl().setExistPop(existPop);
}

Set<MessageQueue> mqAll = null;
boolean changed = this.updateMessageQueueAssignment(topic, messageQueueAssignments, isOrder);
if (changed) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,4 +288,8 @@ public ProcessQueue createProcessQueue() {
public PopProcessQueue createPopProcessQueue() {
return new PopProcessQueue();
}

public DefaultMQPushConsumerImpl getDefaultMQPushConsumerImpl() {
return defaultMQPushConsumerImpl;
}
}
Loading