Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,9 @@ public interface Connector extends Service {
* @return true if connector is started
*/
public boolean isStarted();

/**
* @return connector name
*/
public String getName();
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public String getClientId() {
return connection.getConnectionId();
}

@Override
public String getConnectionId() {
return connection.getConnectionId();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ public interface ConnectionViewMBean extends Service {
@MBeanInfo("client id for this connection")
String getClientId();

/**
* Returns the identifier for this connection
*
* @return the identifier for this connection
*/
@MBeanInfo("ID for this connection")
String getConnectionId();

/**
* Returns the number of messages to be dispatched to this connection
* @return the number of messages pending dispatch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,9 @@ public boolean isAutoStart() {
public boolean isStarted() {
return this.connector.isStarted();
}

@Override
public String getName() {
return this.connector.getName();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,7 @@ public interface ConnectorViewMBean extends Service {
*/
@MBeanInfo("Connector started")
boolean isStarted();

@MBeanInfo("Connector name")
String getName();
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@
<%
Iterator it = broker.getConnections(connectorName).iterator();
while (it.hasNext()) {
String conName = (String) it.next();
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 ?

request.setAttribute(connection, con);
%>
<jsp:doBody/>
Expand Down
6 changes: 3 additions & 3 deletions activemq-web-console/src/main/webapp/connections.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@

<h2>Connections</h2>

<c:forEach items="${requestContext.brokerQuery.connectors}" var="connectorName">
<h3>Connector <c:out value="${connectorName}" /></h3>
<c:forEach items="${requestContext.brokerQuery.connectors}" var="connector">
<h3>Connector <c:out value="${connector.name}" /></h3>

<table id="connections" class="sortable autostripe">
<thead>
Expand All @@ -41,7 +41,7 @@
</tr>
</thead>
<tbody>
<jms:forEachConnection broker="${requestContext.brokerQuery}" connectorName="${connectorName}"
<jms:forEachConnection broker="${requestContext.brokerQuery}" connectorName="${connector.name}"
connection="con" connectionName="conName">
<tr>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,12 @@ Collection<DurableSubscriptionViewMBean> getInactiveDurableTopicSubscribers()
throws Exception;

/**
* The names of all transport connectors of the broker (f.e. openwire, ssl)
* All transport connectors of the broker (f.e. openwire, ssl)
*
* @return not <code>null</code>
* @throws Exception
*/
Collection<String> getConnectors() throws Exception;
Collection<ConnectorViewMBean> getConnectors() throws Exception;

/**
* A transport connectors.
Expand All @@ -160,16 +160,15 @@ Collection<DurableSubscriptionViewMBean> getInactiveDurableTopicSubscribers()
Collection<ConnectionViewMBean> getConnections() throws Exception;

/**
* The names of all connections to a specific transport connectors of the
* broker.
* All connections to a specific transport connectors of the broker.
*
* @see #getConnection(String)
* @param connectorName
* not <code>null</code>
* @return not <code>null</code>
* @throws Exception
*/
Collection<String> getConnections(String connectorName) throws Exception;
Collection<ConnectionViewMBean> getConnections(String connectorName) throws Exception;

/**
* A specific connection to the broker.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,16 +169,13 @@ public Collection<ConnectionViewMBean> getConnections() throws Exception {

@Override
@SuppressWarnings("unchecked")
public Collection<String> getConnections(String connectorName) throws Exception {
public Collection<ConnectionViewMBean> getConnections(String connectorName) throws Exception {
String brokerName = getBrokerName();
ObjectName query = new ObjectName("org.apache.activemq:type=Broker,brokerName=" + brokerName
+ ",connector=clientConnectors,connectorName=" + connectorName + ",connectionViewType=clientId" + ",connectionName=*"); Set<ObjectName> queryResult = queryNames(query, null);
Collection<String> result = new ArrayList<String>(queryResult.size());
for (ObjectName on : queryResult) {
String name = StringUtils.replace(on.getKeyProperty("connectionName"), "_", ":");
result.add(name);
}
return result;
+ ",connector=clientConnectors,connectorName=" + connectorName + ",connectionViewType=clientId,connectionName=*");
Set<ObjectName> queryResult = queryNames(query, null);
return getManagedObjects(queryResult.toArray(new ObjectName[queryResult.size()]),
ConnectionViewMBean.class);
}

@Override
Expand All @@ -198,14 +195,13 @@ public ConnectionViewMBean getConnection(String connectionName) throws Exception

@Override
@SuppressWarnings("unchecked")
public Collection<String> getConnectors() throws Exception {
public Collection<ConnectorViewMBean> getConnectors() throws Exception {
String brokerName = getBrokerName();
ObjectName query = new ObjectName("org.apache.activemq:type=Broker,brokerName=" + brokerName + ",connector=clientConnectors,connectorName=*");
Set<ObjectName> queryResult = queryNames(query, null);
Collection<String> result = new ArrayList<String>(queryResult.size());
for (ObjectName on : queryResult)
result.add(on.getKeyProperty("connectorName"));
return result;
return getManagedObjects(queryResult.toArray(new ObjectName[queryResult.size()]),
ConnectorViewMBean.class);
}

@Override
Expand Down