Skip to content

Conversation

thezbyg
Copy link
Contributor

@thezbyg thezbyg commented Sep 14, 2025

No description provided.

@jbonofre jbonofre self-requested a review September 25, 2025 06:09
ConnectionViewMBean con = broker.getConnection(conName);
request.setAttribute(connectionName, conName);
ConnectionViewMBean con = (ConnectionViewMBean) it.next();
request.setAttribute(connectionName, con.getClientId());
Copy link
Member

Choose a reason for hiding this comment

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

I'm a bit confused here. Is it con.getCliientId() or connection name MBean constructed.
Can you please just add a comment here to explain the use of clientId (instead of constructing with the name, and more) ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Heads up-- iirc, there are inconsistencies in connection name/id/clientId.

Some protocols only allow a single clientId-per-broker (mqtt) and some can in certain scenarios (jms). We need to be super sure about which is used to avoid a scenario where the web ui can have two entries for the same id in a list view.

Copy link
Member

Choose a reason for hiding this comment

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

That's my point here. I'm a bit concerned by this connection name here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jbonofre
Connection MBeans with connectionViewType=clientId type use connection clientId value for connectionName parameter, so connectionName MBean parameter value and clientId connection property value should be equivalent.

This is the code responsible for connectionName value in connection MBean:


return BrokerMBeanSupport.createConnectionViewByType(connectorName, type, value);

objectNameStr += ",connectionName="+ JMXSupport.encodeObjectNamePart(name);

@mattrpav
If JMS allows multiple connections with same clientId value, then it should have already caused problems by attempting to create multiple MBeans with the same name. If this was not an issue before my changes, then I will have to investigate more, because I thought that clientId must always be unique and can not be shared between connections.

Copy link
Member

Choose a reason for hiding this comment

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

@thezbyg thanks for your feedback. It looks good. Let me do a new pass, but I think it's good to merge. @mattrpav thoughts ?

Copy link
Member

@jbonofre jbonofre left a comment

Choose a reason for hiding this comment

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

LGTM, imho, it would be great to add a little comment to frame use of con.getClientId().

@jbonofre jbonofre self-requested a review September 29, 2025 15:10
@mattrpav
Copy link
Contributor

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.

@thezbyg
Copy link
Contributor Author

thezbyg commented Sep 30, 2025

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.

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.

3 participants