Skip to content

Reproduce an MDB with maxSessions=1 that stops consuming after its work is rejected - #3090

Draft
rzo1 wants to merge 1 commit into
mainfrom
mdb-work-rejection-repro
Draft

rzo1 wants to merge 1 commit into
mainfrom
mdb-work-rejection-repro

Conversation

@rzo1

@rzo1 rzo1 commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Reproducer for the "MDB pool drops instances on RejectedExecutionException" thread on dev@. Not meant to be merged as is. The test fails on purpose.

What the test does

The ActiveMQ resource adapter gets threadPoolSize=2, QueueSize=1 and OfferTimeout=1 second.

  1. A blocking MDB occupies both pool threads and the single queue slot.
  2. A message is sent to an MDB with maxSessions=1. Scheduling its ServerSession work is rejected after the offer timeout.
  3. The blocking MDB is released, so the pool recovers.
  4. Another message is sent to the maxSessions=1 MDB. It is never consumed.

With -DofferTimeout="30 seconds" the work only waits and is never rejected, and the test passes. The rejection is what kills the consumer.

mvn -pl container/openejb-core test -Dtest=MdbWorkRejectionTest
mvn -pl container/openejb-core test -Dtest=MdbWorkRejectionTest -DofferTimeout="30 seconds"

Analysis

The code involved is identical in 10.2.0 (activemq-ra 6.2.7, geronimo-connector 4.0.0) and on main (activemq-ra 6.3.2).

  • geronimo-connector 4.0.0: GeronimoWorkManager.executeWork lets RejectedExecutionException escape. ServerSessionImpl.start() only catches WorkException, so running stays true. The session stays in activeSessions without a thread and is never considered stale. With maxSessions=1 the consumer is dead for good; with more sessions a slot leaks per rejection. Nothing is logged.
  • With GERONIMO-6911 (apache/geronimo-txmanager#10, verified with a local 4.0.1-SNAPSHOT via -Dversion.geronimo.components=4.0.1-SNAPSHOT): start() fails with a JMSException, which reaches the exception listener of ActiveMQEndpointWorker. The listener disconnects and calls connect(), which schedules the reconnect on the same, still saturated WorkManager. On WorkException it sets running = false and logs "Work Manager did not accept work", so the endpoint never reconnects. The test fails the same way, with this sequence in the log:
WARN  Failed to schedule work for session ServerSessionImpl:{...}, marking not running (WorkRejectedException)
ERROR Connection to broker failed: Start failed: jakarta.resource.spi.work.WorkRejectedException: The execution has been rejected.
ERROR Work Manager did not accept work: (WorkRejectedException)

Both holes are in activemq-ra (ServerSessionImpl.start() and ActiveMQEndpointWorker.connect()), so the fix most likely belongs upstream.

…rk is rejected

Saturates the thread pool of the ActiveMQ resource adapter so that scheduling
the ServerSession work fails, then checks the MDB consumes again once the
pool recovers. It does not, see the 'MDB pool drops instances on
RejectedExecutionException' thread on dev@.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant