Skip to content

Set connection timeouts on ActiveMQ factory to prevent indefinite hangs - #383

Merged
ggallen merged 2 commits into
jenkinsci:masterfrom
ggallen:fix/amq-connection-timeout
Aug 5, 2026
Merged

Set connection timeouts on ActiveMQ factory to prevent indefinite hangs#383
ggallen merged 2 commits into
jenkinsci:masterfrom
ggallen:fix/amq-connection-timeout

Conversation

@ggallen

@ggallen ggallen commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Sets connectResponseTimeout (60s) and sendTimeout (60s) on every ActiveMQConnectionFactory returned by ActiveMqMessagingProvider.getConnectionFactory()
  • Without these timeouts, setClientID()ensureConnectionInfoSent()syncSendPacket() blocks forever on FutureResponse.getResult() when the broker is unresponsive
  • Adds a deaf-server integration test that verifies connect() fails cleanly instead of hanging
  • Adds a unit test verifying the factory timeout properties are set

Fixes #381

Test plan

  • New test connect_deafBroker_failsWithinTimeout — spins up a TCP server that accepts connections but never speaks OpenWire; verifies connect() returns false within a bounded time
  • New test getConnectionFactory_setsTimeouts — verifies connectResponseTimeout and sendTimeout are set on the returned factory
  • All existing unit tests pass
  • CI integration tests pass

🤖 Generated with Claude Code

@ggallen
ggallen requested a review from a team as a code owner August 5, 2026 12:14
ActiveMQConnectionFactory was created with no timeouts, causing
setClientID() → ensureConnectionInfoSent() → syncSendPacket() to block
forever when a broker becomes unresponsive.

Sets connectResponseTimeout and sendTimeout (60s each) on every factory
returned by getConnectionFactory(), ensuring connect() fails with a
JMSException instead of hanging indefinitely.

Fixes jenkinsci#381

Signed-off-by: Greg Allen <gallen@redhat.com>
Signed-off-by: Claude Opus 4.6 <noreply@anthropic.com>
@ggallen
ggallen force-pushed the fix/amq-connection-timeout branch from ee226bc to a7feabf Compare August 5, 2026 12:48
Guard against getConnectionFactory() returning null in connect(),
sendMessage(), and waitForMessage() to prevent NPE when credentials
are not yet loaded at boot. Broaden subscribe()'s catch to include
RuntimeException so unexpected errors don't kill the subscriber thread.

Incorporates improvements from PR jenkinsci#382 by @hareldev.

Signed-off-by: Greg Allen <gallen@redhat.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Greg Allen <gallen@redhat.com>
@ggallen
ggallen merged commit 5e1ab4c into jenkinsci:master Aug 5, 2026
15 checks passed
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.

JMS connection setup can hang forever with no timeout, silently dropping CI messages

1 participant