activemq icon indicating copy to clipboard operation
activemq copied to clipboard

[AMQ-9769] Add name property to connector interface and MBean.

Open thezbyg opened this issue 3 months ago • 4 comments

thezbyg avatar Sep 14 '25 06:09 thezbyg

Requested change:

  1. Please add getConnectionId() to ConnectionViewMBean

The connectionId is the unique value within the broker for the connection.

Side note: We should be registering JMX using that unique value instead of the clientId since clientId can be reused across connections and quickly swapped out if link stealing is enabled, but we won't dial up that change now.

mattrpav avatar Sep 30 '25 11:09 mattrpav

Done, but now ConnectionView returns the same value for both getClientId and getConnectionId:

public String getClientId() {
    return connection.getConnectionId();
}
public String getConnectionId() {
    return connection.getConnectionId();
}

And connection.getConnectionId() executes the following code in TransportConnection class:

    public String getConnectionId() {
        List<TransportConnectionState> connectionStates = listConnectionStates();
        for (TransportConnectionState cs : connectionStates) {
            if (cs.getInfo().getClientId() != null) {
                return cs.getInfo().getClientId();
            }
            return cs.getInfo().getConnectionId().toString();
        }
        return null;
    }

So it may return either clientId or connectionId.

I propose to remove connection handling changes from this pull request and keep only changes to connector MBean and connector output in web UI.

thezbyg avatar Sep 30 '25 13:09 thezbyg

@thezbyg can you please rebase and fix conflict ?

jbonofre avatar Nov 03 '25 07:11 jbonofre

Rebased.

Connection clientId issue could be fixed by saving current clientId value when registering connection MBean. Like this: https://github.com/thezbyg/activemq/commit/53d7e53366b88ceb00d6f5a08aad5bd83c618891 This would ensure that clientId returned by connection.getClientId() could not change after MBean is registered and would always match connectionName property value in connection MBean object name.

thezbyg avatar Nov 03 '25 18:11 thezbyg