apache/rocketmq · warning · MQClientException

The message queue is not in assigned list, may be rebalancin

Error message

The message queue is not in assigned list, may be rebalancing, message queue: 

What it means

DefaultLitePullConsumerImpl.seek() throws this MQClientException when the given MessageQueue is not in the assigned queue list AND the consumer is in SUBSCRIBE mode (queues managed by rebalancing). The suffix "may be rebalancing" signals that rebalance has (possibly temporarily) moved the queue away from this consumer, so seeking it locally is impossible.

Source

Thrown at client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultLitePullConsumerImpl.java:669

        } catch (InterruptedException ignore) {

        }

        return Collections.emptyList();
    }

    public void pause(Collection<MessageQueue> messageQueues) {
        assignedMessageQueue.pause(messageQueues);
    }

    public void resume(Collection<MessageQueue> messageQueues) {
        assignedMessageQueue.resume(messageQueues);
    }

    public synchronized void seek(MessageQueue messageQueue, long offset) throws MQClientException {
        if (!assignedMessageQueue.getAssignedMessageQueues().contains(messageQueue)) {
            if (subscriptionType == SubscriptionType.SUBSCRIBE) {
                throw new MQClientException("The message queue is not in assigned list, may be rebalancing, message queue: " + messageQueue, null);
            } else {
                throw new MQClientException("The message queue is not in assigned list, message queue: " + messageQueue, null);
            }
        }
        long minOffset = minOffset(messageQueue);
        long maxOffset = maxOffset(messageQueue);
        if (offset < minOffset || offset > maxOffset) {
            throw new MQClientException("Seek offset illegal, seek offset = " + offset + ", min offset = " + minOffset + ", max offset = " + maxOffset, null);
        }
        final Object objLock = messageQueueLock.fetchLockObject(messageQueue);
        synchronized (objLock) {
            clearMessageQueueInCache(messageQueue);

            PullTaskImpl oldPullTaskImpl = this.taskTable.get(messageQueue);
            if (oldPullTaskImpl != null) {
                oldPullTaskImpl.tryInterrupt();
                this.taskTable.remove(messageQueue);
            }

View on GitHub (pinned to 293f588571)

Solutions

  1. Wait for rebalance to settle (e.g. check assignedMessageQueue via getAssignedMessageQueue()) then retry seek
  2. Only seek queues you obtained from the current assignment, not from fetchMessageQueues
  3. Stabilize the consumer group (fixed instance count) to stop queues flapping

Example fix

// before
consumer.seek(queueFromFetch, offset);

// after
if (consumer.getAssignedMessageQueue().getAssignedMessageQueues().contains(queueFromFetch)) {
    consumer.seek(queueFromFetch, offset);
} else {
    // wait for rebalance and retry, or log and skip
}
Defensive patterns

Strategy: retry

Validate before calling

if (consumer.getAssignedMessageQueue().getAssignedMessageQueues().contains(messageQueue)) {
    consumer.seek(messageQueue, offset);
}

Try / catch

try {
    consumer.seek(q, offset);
} catch (MQClientException e) {
    if (e.getMessage().contains("may be rebalancing")) {
        // transient: sleep briefly, verify assignment, retry seek once
    } else throw e;
}

Prevention

When it happens

Trigger: Calling seek(queue, offset) for a queue obtained from fetchMessageQueues(topic) rather than the currently assigned set; seeking during a rebalance that reassigned the queue to another consumer in the group.

Common situations: Group membership churn (consumers joining/leaving) causing queues to move; seeking immediately after start() before the first rebalance completes; using a queue from a previous assignment.

Related errors


AI-assisted analysis of apache/rocketmq@293f588571 (2026-08-14). Data as JSON: /api/errors/c65ecee92c87b335. Report an issue: GitHub.