apache/rocketmq · error · IllegalArgumentException

currentCID is empty

Error message

currentCID is empty

What it means

QueryAssignmentProcessor.allocate (server-side static/rebalancing assignment for QUERY_ASSIGNMENT when exclusive consumer mode is on) validates that the requesting client's clientId is non-blank. A blank currentCID fails fast with IllegalArgumentException.

Source

Thrown at broker/src/main/java/org/apache/rocketmq/broker/processor/QueryAssignmentProcessor.java:279

                        index++;
                        index = index % cidAll.size();
                        List<MessageQueue> tmp = allocateMessageQueueStrategy.allocate(consumerGroup, cidAll.get(index), mqAll, cidAll);
                        allocateResult.addAll(tmp);
                    }
                }
            } else {
                //make sure each cid is assigned
                allocateResult = allocate(consumerGroup, clientId, mqAll, cidAll);
            }
        }

        return allocateResult;
    }

    private List<MessageQueue> allocate(String consumerGroup, String currentCID, List<MessageQueue> mqAll,
        List<String> cidAll) {
        if (StringUtils.isBlank(currentCID)) {
            throw new IllegalArgumentException("currentCID is empty");
        }

        if (CollectionUtils.isEmpty(mqAll)) {
            throw new IllegalArgumentException("mqAll is null or mqAll empty");
        }
        if (CollectionUtils.isEmpty(cidAll)) {
            throw new IllegalArgumentException("cidAll is null or cidAll empty");
        }

        List<MessageQueue> result = new ArrayList<>();
        if (!cidAll.contains(currentCID)) {
            log.info("[BUG] ConsumerGroup: {} The consumerId: {} not in cidAll: {}",
                consumerGroup,
                currentCID,
                cidAll);
            return result;
        }

View on GitHub (pinned to 293f588571)

Solutions

  1. Ensure the consumer client sets a unique non-empty clientId (DEFAULT_MQ_CONSUMER default is IP@instanceName).
  2. If instanceName is overridden, verify it isn't blank and the client is a stock supported version.
  3. Upgrade third-party clients to versions that populate clientId on QUERY_ASSIGNMENT requests.

Example fix

// before
consumer.setClientIP(""); // or instanceName blank -> blank clientId

// after
consumer.setInstanceName(String.valueOf(System.currentTimeMillis())); // ensures non-empty unique clientId
Defensive patterns

Strategy: validation

Validate before calling

if (StringUtils.isBlank(requestHeader.getClientId())) {
    throw new IllegalArgumentException("clientId must be set before QUERY_ASSIGNMENT");
}

Type guard

boolean hasValidClientId(String clientId) { return clientId != null && !clientId.trim().isEmpty(); }

Prevention

When it happens

Trigger: QUERY_ASSIGNMENT request whose clientId header is empty/whitespace — broken or non-compliant client, or a custom client not setting clientId.

Common situations: Custom SDK/proxy omitting clientId; clientId trimmed to empty by config; older client versions incompatible with the exclusive-consume assignment path.

Related errors


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