This closes #2390
This commit is contained in:
commit
8bf549b7c6
|
@ -38,14 +38,6 @@ public interface ClientSession extends XAResource, AutoCloseable {
|
||||||
*/
|
*/
|
||||||
String JMS_SESSION_IDENTIFIER_PROPERTY = "jms-session";
|
String JMS_SESSION_IDENTIFIER_PROPERTY = "jms-session";
|
||||||
|
|
||||||
/**
|
|
||||||
* Just like {@link ClientSession.AddressQuery#JMS_SESSION_IDENTIFIER_PROPERTY} this is
|
|
||||||
* used to identify the ClientID over JMS Session.
|
|
||||||
* However this is only used when the JMS Session.clientID is set (which is optional).
|
|
||||||
* With this property management tools and the server can identify the jms-client-id used over JMS
|
|
||||||
*/
|
|
||||||
String JMS_SESSION_CLIENT_ID_PROPERTY = "jms-client-id";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Information returned by a binding query
|
* Information returned by a binding query
|
||||||
*
|
*
|
||||||
|
|
|
@ -79,6 +79,14 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme
|
||||||
|
|
||||||
public static final SimpleString CONNECTION_ID_PROPERTY_NAME = MessageUtil.CONNECTION_ID_PROPERTY_NAME;
|
public static final SimpleString CONNECTION_ID_PROPERTY_NAME = MessageUtil.CONNECTION_ID_PROPERTY_NAME;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Just like {@link ClientSession.AddressQuery#JMS_SESSION_IDENTIFIER_PROPERTY} this is
|
||||||
|
* used to identify the ClientID over JMS Session.
|
||||||
|
* However this is only used when the JMS Session.clientID is set (which is optional).
|
||||||
|
* With this property management tools and the server can identify the jms-client-id used over JMS
|
||||||
|
*/
|
||||||
|
public static String JMS_SESSION_CLIENT_ID_PROPERTY = "jms-client-id";
|
||||||
|
|
||||||
// Static ---------------------------------------------------------------------------------------
|
// Static ---------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Attributes -----------------------------------------------------------------------------------
|
// Attributes -----------------------------------------------------------------------------------
|
||||||
|
@ -265,7 +273,7 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme
|
||||||
private void validateClientID(ClientSession validateSession, String clientID)
|
private void validateClientID(ClientSession validateSession, String clientID)
|
||||||
throws InvalidClientIDException, ActiveMQException {
|
throws InvalidClientIDException, ActiveMQException {
|
||||||
try {
|
try {
|
||||||
validateSession.addUniqueMetaData(ClientSession.JMS_SESSION_CLIENT_ID_PROPERTY, clientID);
|
validateSession.addUniqueMetaData(JMS_SESSION_CLIENT_ID_PROPERTY, clientID);
|
||||||
} catch (ActiveMQException e) {
|
} catch (ActiveMQException e) {
|
||||||
if (e.getType() == ActiveMQExceptionType.DUPLICATE_METADATA) {
|
if (e.getType() == ActiveMQExceptionType.DUPLICATE_METADATA) {
|
||||||
throw new InvalidClientIDException("clientID=" + clientID + " was already set into another connection");
|
throw new InvalidClientIDException("clientID=" + clientID + " was already set into another connection");
|
||||||
|
@ -690,7 +698,7 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme
|
||||||
if (validateClientId) {
|
if (validateClientId) {
|
||||||
validateClientID(initialSession, clientID);
|
validateClientID(initialSession, clientID);
|
||||||
} else {
|
} else {
|
||||||
initialSession.addMetaData(ClientSession.JMS_SESSION_CLIENT_ID_PROPERTY, clientID);
|
initialSession.addMetaData(JMS_SESSION_CLIENT_ID_PROPERTY, clientID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -706,7 +714,7 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme
|
||||||
private void addSessionMetaData(ClientSession session) throws ActiveMQException {
|
private void addSessionMetaData(ClientSession session) throws ActiveMQException {
|
||||||
session.addMetaData(ClientSession.JMS_SESSION_IDENTIFIER_PROPERTY, "");
|
session.addMetaData(ClientSession.JMS_SESSION_IDENTIFIER_PROPERTY, "");
|
||||||
if (clientID != null) {
|
if (clientID != null) {
|
||||||
session.addMetaData(ClientSession.JMS_SESSION_CLIENT_ID_PROPERTY, clientID);
|
session.addMetaData(JMS_SESSION_CLIENT_ID_PROPERTY, clientID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,7 @@ import org.apache.activemq.artemis.api.core.client.ClusterTopologyListener;
|
||||||
import org.apache.activemq.artemis.api.core.client.TopologyMember;
|
import org.apache.activemq.artemis.api.core.client.TopologyMember;
|
||||||
import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
|
import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
|
||||||
import org.apache.activemq.artemis.core.client.impl.ClientSessionInternal;
|
import org.apache.activemq.artemis.core.client.impl.ClientSessionInternal;
|
||||||
|
import org.apache.activemq.artemis.jms.client.ActiveMQConnection;
|
||||||
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
|
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
|
||||||
import org.apache.activemq.artemis.jms.client.ActiveMQDestination;
|
import org.apache.activemq.artemis.jms.client.ActiveMQDestination;
|
||||||
import org.apache.activemq.artemis.ra.ActiveMQRABundle;
|
import org.apache.activemq.artemis.ra.ActiveMQRABundle;
|
||||||
|
@ -492,7 +493,7 @@ public class ActiveMQActivation {
|
||||||
result.addMetaData(ClientSession.JMS_SESSION_IDENTIFIER_PROPERTY, "");
|
result.addMetaData(ClientSession.JMS_SESSION_IDENTIFIER_PROPERTY, "");
|
||||||
String clientID = ra.getClientID() == null ? spec.getClientID() : ra.getClientID();
|
String clientID = ra.getClientID() == null ? spec.getClientID() : ra.getClientID();
|
||||||
if (clientID != null) {
|
if (clientID != null) {
|
||||||
result.addMetaData(ClientSession.JMS_SESSION_CLIENT_ID_PROPERTY, clientID);
|
result.addMetaData(ActiveMQConnection.JMS_SESSION_CLIENT_ID_PROPERTY, clientID);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.debug("Using queue connection " + result);
|
logger.debug("Using queue connection " + result);
|
||||||
|
|
|
@ -23,10 +23,10 @@ import javax.jms.InvalidClientIDException;
|
||||||
import javax.jms.JMSException;
|
import javax.jms.JMSException;
|
||||||
|
|
||||||
import org.apache.activemq.artemis.api.core.ActiveMQException;
|
import org.apache.activemq.artemis.api.core.ActiveMQException;
|
||||||
import org.apache.activemq.artemis.api.core.client.ClientSession;
|
|
||||||
import org.apache.activemq.artemis.core.config.Configuration;
|
import org.apache.activemq.artemis.core.config.Configuration;
|
||||||
import org.apache.activemq.artemis.core.server.ServerSession;
|
import org.apache.activemq.artemis.core.server.ServerSession;
|
||||||
import org.apache.activemq.artemis.core.server.plugin.ActiveMQServerPlugin;
|
import org.apache.activemq.artemis.core.server.plugin.ActiveMQServerPlugin;
|
||||||
|
import org.apache.activemq.artemis.jms.client.ActiveMQConnection;
|
||||||
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
|
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
|
||||||
import org.apache.activemq.artemis.tests.util.JMSTestBase;
|
import org.apache.activemq.artemis.tests.util.JMSTestBase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -49,7 +49,7 @@ public class SessionMetadataAddExceptionTest extends JMSTestBase {
|
||||||
public void beforeSessionMetadataAdded(ServerSession session, String key, String data)
|
public void beforeSessionMetadataAdded(ServerSession session, String key, String data)
|
||||||
throws ActiveMQException {
|
throws ActiveMQException {
|
||||||
|
|
||||||
if (ClientSession.JMS_SESSION_CLIENT_ID_PROPERTY.equals(key)) {
|
if (ActiveMQConnection.JMS_SESSION_CLIENT_ID_PROPERTY.equals(key)) {
|
||||||
if ("invalid".equals(data)) {
|
if ("invalid".equals(data)) {
|
||||||
throw new ActiveMQException("Invalid clientId");
|
throw new ActiveMQException("Invalid clientId");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1572,7 +1572,7 @@ public class ActiveMQServerControlTest extends ManagementTestBase {
|
||||||
JsonArray array = JsonUtil.readJsonArray(jsonString);
|
JsonArray array = JsonUtil.readJsonArray(jsonString);
|
||||||
Assert.assertEquals(1 + (usingCore() ? 1 : 0), array.size());
|
Assert.assertEquals(1 + (usingCore() ? 1 : 0), array.size());
|
||||||
JsonObject obj = lookupSession(array, ((ActiveMQConnection)con).getInitialSession());
|
JsonObject obj = lookupSession(array, ((ActiveMQConnection)con).getInitialSession());
|
||||||
Assert.assertEquals(obj.getJsonObject("metadata").getJsonString(ClientSession.JMS_SESSION_CLIENT_ID_PROPERTY).getString(), clientID);
|
Assert.assertEquals(obj.getJsonObject("metadata").getJsonString(ActiveMQConnection.JMS_SESSION_CLIENT_ID_PROPERTY).getString(), clientID);
|
||||||
Assert.assertNotNull(obj.getJsonObject("metadata").getJsonString(ClientSession.JMS_SESSION_IDENTIFIER_PROPERTY));
|
Assert.assertNotNull(obj.getJsonObject("metadata").getJsonString(ClientSession.JMS_SESSION_IDENTIFIER_PROPERTY));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue