apache / apache/activemq

Jolokia/JMX queries fail with IllegalStateException on slave broker when startAsync=true

Open
#2,551 0 comments 0 reactions 1 assignee Claimed by @jbonofre View on GitHub
Dominant language
Java
Stars
2.5k
Forks
1.5k
Avg merge
10h 46m
Merged PRs (30d)
79

Description

## Problem

When a broker is configured with `startAsync=true` and is running as a slave (blocked waiting on the shared/exclusive lock), Jolokia queries against the Broker MBean fail with:

```
java.lang.IllegalStateException: Broker is not yet started.
```

Browsing the same MBean directly in JConsole shows all attributes correctly, including `Slave=true`.

## Root cause

In `BrokerView.java`, most attribute getters are safe to call before the `ManagedRegionBroker` object exists — for example `isSlave()` reads directly from `BrokerService` and never touches it. However, a few getters — `getBrokerId()`, `getBrokerName()`, plus several destination/statistics getters — call `safeGetBroker()`, which throws `IllegalStateException("Broker is not yet started.")` while the slave is still waiting on the lock.

Since Jolokia reads all attributes on an MBean in a single batch request, that one exception aborts the entire response, so attributes that would have succeeded independently (such as `Slave`) never come back either.

## Environment

- `startAsync=true`
- Broker running as slave, blocked on lock acquisition

## Suggested fix

Have the read-only getters in `BrokerView` return a safe fallback instead of throwing when the `ManagedRegionBroker` isn't set yet:
- broker name falls back to the configured name on `BrokerService`
- broker ID returns `null`
- counts return `0`
- lists return empty

Getters that actually mutate broker state (add/remove destinations, durable subscriptions, stats reset) should keep throwing, since those genuinely can't run yet.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.