apache/rocketmq · error · MQClientException

consumeTimestamp is invalid, the valid format is yyyyMMddHHm

Error message

consumeTimestamp is invalid, the valid format is yyyyMMddHHmmss,but received {consumeTimestamp}

What it means

checkConfig() parses consumeTimestamp with UtilAll.parseDate(value, "yyyyMMddHHmmss") and throws when parsing yields null. The timestamp only matters for CONSUME_FROM_TIMESTAMP mode, but it is validated on every start(). DefaultMQPushConsumer ships a valid default, so failure means a user-supplied string in the wrong format.

Source

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

        }

        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),
                null);
        }

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

View on GitHub (pinned to 293f588571)

Solutions

  1. Use exactly 14 digits yyyyMMddHHmmss, e.g. 20240101000000
  2. If you want 'now', simply leave the default (a sentinel meaning current time) rather than formatting Date yourself
  3. Validate the format in config loading (regex ^\d{14}$) so bad values fail before start()

Example fix

// before
consumer.setConsumeTimestamp("2024-01-01 00:00:00");

// after
consumer.setConsumeTimestamp("20240101000000");
Defensive patterns

Strategy: validation

Validate before calling

if (consumeTimestamp != null && !consumeTimestamp.matches("^\\d{14}$"))
    throw new IllegalArgumentException("consumeTimestamp must be yyyyMMddHHmmss: " + consumeTimestamp);
consumer.setConsumeTimestamp(consumeTimestamp);

Type guard

boolean isValidConsumeTimestamp(String s) { return s == null || s.matches("^\\d{14}$"); }

Prevention

When it happens

Trigger: Calling setConsumeTimestamp("2024-01-01 00:00:00") or any non-numeric format; passing a millisecond-epoch string; trailing/leading whitespace or an empty string after explicit set.

Common situations: Copying an ISO-8601 timestamp from logs into config; feeding an epoch-millis value; i18n date formats from config files.

Related errors


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