Skip to content

Fix network bridge local-side close - #2475

Open
mattrpav wants to merge 2 commits into
apache:mainfrom
mattrpav:amq-harden-netbridge-local-close
Open

Fix network bridge local-side close#2475
mattrpav wants to merge 2 commits into
apache:mainfrom
mattrpav:amq-harden-netbridge-local-close

Conversation

@mattrpav

@mattrpav mattrpav commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Currently, a local-side connection close is treated as the same as a broker shutdown. The bridge is stopped, but not removed from activeBridges or restarted.

This fix differentiates between an administrative close (inactivity monitor, connection.close(), etc.) to ensure the bridge is closed, cleared and recreated.

@cshannon cshannon left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattrpav - Ok, I played around with this a bunch and I think it will work after all because of the disposed flag. That flag gets checked before anything happens in both serviceLocalCommand and serviceRemoteCommand. The disposed flag gets set to true when a bridge is stopped on purpose.

My main concern here was making sure that if the ShutDownInfo command is received that we only process and trigger the restart if there was an unexpected close. On a normal bridge shtudown the command won't get processed because disposed is set to true so all of that is skipped.

Also, you pointed out that the serviceRemoteCommand does the same thing on ShutdownInfo by calling the exception handler which triggers the bridge failed and reconnect as well so that further verifies this should be ok.

I made one comment inline that I think the test should simulate how the connection is stopped by the slow consumer strategy with an exception here

Also it would be good to expand on the tests:

  1. I would make sure duplex bridges are also handled correctly with reconnect
  2. You could try and test that the bridge doesn't reconnect if you stopped and and connection.serviceException() is called (this might already be tested by other bridge tests not sure)

var bridgeLocalConnection = findVmConnection(localBroker);
assertNotNull("expected the bridge's local vm:// connection on the local broker", bridgeLocalConnection);
LOG.info("stopping the bridge's local connection server-side: {}", bridgeLocalConnection);
bridgeLocalConnection.stop();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably simulate passing an IOException just like the slow consumer strategy does

@mattrpav mattrpav changed the title [#] Fix network bridge local-side close Fix network bridge local-side close Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

2 participants