apache/rocketmq · error · MQClientException

consumeFromWhere is null

Error message

consumeFromWhere is null

What it means

checkConfig() requires consumeFromWhere (CONSUME_FROM_LAST_OFFSET, CONSUME_FROM_FIRST_OFFSET, or CONSUME_FROM_MIN_OFFSET) to be set. Like messageModel, this field has a default (CONSUME_FROM_LAST_OFFSET), so null indicates an explicit null assignment or an aggressive mock/reflection setup.

Source

Thrown at client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java:1052

        if (this.defaultMQPushConsumer.getConsumerGroup().equals(MixAll.DEFAULT_CONSUMER_GROUP)) {
            throw new MQClientException(
                "consumerGroup can not equal "
                    + MixAll.DEFAULT_CONSUMER_GROUP
                    + ", please specify another one."
                    + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
                null);
        }

        if (null == this.defaultMQPushConsumer.getMessageModel()) {
            throw new MQClientException(
                "messageModel is null"
                    + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
                null);
        }

        if (null == this.defaultMQPushConsumer.getConsumeFromWhere()) {
            throw new MQClientException(
                "consumeFromWhere is null"
                    + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
                null);
        }

        Date dt = UtilAll.parseDate(this.defaultMQPushConsumer.getConsumeTimestamp(), UtilAll.YYYYMMDDHHMMSS);
        if (null == dt) {
            throw new MQClientException(
                "consumeTimestamp is invalid, the valid format is yyyyMMddHHmmss,but received "
                    + this.defaultMQPushConsumer.getConsumeTimestamp()
                    + " " + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL), null);
        }

        // allocateMessageQueueStrategy
        if (null == this.defaultMQPushConsumer.getAllocateMessageQueueStrategy()) {
            throw new MQClientException(
                "allocateMessageQueueStrategy is null"
                    + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),

View on GitHub (pinned to 293f588571)

Solutions

  1. Always set consumeFromWhere explicitly (CONSUME_FROM_LAST_OFFSET is the conventional default for new groups)
  2. Treat null in deserialized config as an error and reject it during config load
  3. Avoid setConsumeFromWhere(null); keep the field default if you have no preference

Example fix

// before
consumer.setConsumeFromWhere(null);

// after
consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_LAST_OFFSET);
Defensive patterns

Strategy: validation

Validate before calling

ConsumeFromWhere where = config.getConsumeFromWhere() != null
    ? config.getConsumeFromWhere() : ConsumeFromWhere.CONSUME_FROM_LAST_OFFSET;
consumer.setConsumeFromWhere(where);

Prevention

When it happens

Trigger: Calling setConsumeFromWhere(null); reflective object construction (e.g. serialization frameworks or unit-test mocks) that bypasses field initializers.

Common situations: Deserializing consumer configuration from JSON/YAML where the consumeFromWhere key maps to null; hand-rolled builders copying null fields.

Related errors


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