alibaba/spring-cloud-alibaba · error · IllegalStateException
DefaultMQPushConsumer not initialized
Error message
DefaultMQPushConsumer not initialized
What it means
doStart throws IllegalStateException when pushConsumer is null - the adapter was never initialized (constructor failed or never ran), yet lifecycle start() was invoked. It is an internal-state assertion: you cannot start a consumer that was not built.
Source
Thrown at spring-cloud-alibaba-starters/spring-cloud-starter-stream-rocketmq/src/main/java/com/alibaba/cloud/stream/binder/rocketmq/integration/inbound/RocketMQInboundChannelAdapter.java:191
}
catch (Exception e) {
log.warn("consume message failed. messageExt:{}", messageExt, e);
return failSupplier.get();
}
}
return sucSupplier.get();
}
@Override
protected void doStart() {
if (extendedConsumerProperties.getExtension() == null
|| !extendedConsumerProperties.getExtension().getEnabled()) {
return;
}
Instrumentation instrumentation = new Instrumentation(topic, this);
try {
if (pushConsumer == null) {
throw new IllegalStateException("DefaultMQPushConsumer not initialized");
}
String subscription = extendedConsumerProperties.getExtension()
.getSubscription();
pushConsumer.subscribe(topic, RocketMQUtils.getMessageSelector(
subscription != null ? subscription : ""));
pushConsumer.start();
instrumentation.markStartedSuccessfully();
}
catch (Exception e) {
instrumentation.markStartFailed(e);
log.error("DefaultMQPushConsumer init failed, Caused by " + e.getMessage());
throw new MessagingException(MessageBuilder.withPayload(
"DefaultMQPushConsumer init failed, Caused by " + e.getMessage())
.build(), e);
}
finally {
InstrumentationManager.addHealthInstrumentation(instrumentation);
}View on GitHub (pinned to 115d590110)
Solutions
- Check the logs for an earlier [123] init failure that left pushConsumer null and fix that root cause.
- Ensure the binding extension `enabled=true` and the constructor path completes.
- Avoid manually constructing/starting the adapter; let Spring manage its lifecycle.
Defensive patterns
Strategy: validation
Validate before calling
// Assert readiness before start.
if (adapter.getPushConsumer() == null) {
throw new IllegalStateException("Cannot start: pushConsumer was never initialized; resolve the prior init failure.");
} Prevention
- Never ignore earlier consumer init failures - they leave the adapter half-built.
- Let Spring Cloud Stream own the adapter lifecycle.
- Verify `enabled=true` for bindings you expect to consume from.
When it happens
Trigger: doStart() executes while the pushConsumer field is still null - e.g. constructor initialization was skipped/failed, or the extension is enabled but construction threw and left the field null.
Common situations: A previous init exception was swallowed; the binding's `enabled` flipped after partial init; bean lifecycle/aspect interfering with the constructor; manual instantiation of the adapter without calling its initializer.
Related errors
- DefaultMQPushConsumer init failed, Caused by {e.getMessage()
- pull consumer already running. {this.toString()}
- defaultMQProducer not initialized
- ConfigService is not initialized
- group must be configured for DLQ{destination.getName()}
AI-assisted analysis of alibaba/spring-cloud-alibaba@115d590110 (2026-08-14).
Data as JSON: /api/errors/df67f4a3f2da748a.
Report an issue: GitHub.