NO-JIRA Move JMS_SESSION_CLIENT_ID_PROPERTY to JMS module

Remove JMS specifics from CORE, that are not used in broker
This commit is contained in:
Michael André Pearce 2018-10-24 02:24:39 +01:00 committed by Clebert Suconic
parent 33f679978a
commit 99a3f17aa0
5 changed files with 16 additions and 15 deletions

View File

@ -38,14 +38,6 @@ public interface ClientSession extends XAResource, AutoCloseable {
*/
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
*

View File

@ -79,6 +79,14 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme
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 ---------------------------------------------------------------------------------------
// Attributes -----------------------------------------------------------------------------------
@ -265,7 +273,7 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme
private void validateClientID(ClientSession validateSession, String clientID)
throws InvalidClientIDException, ActiveMQException {
try {
validateSession.addUniqueMetaData(ClientSession.JMS_SESSION_CLIENT_ID_PROPERTY, clientID);
validateSession.addUniqueMetaData(JMS_SESSION_CLIENT_ID_PROPERTY, clientID);
} catch (ActiveMQException e) {
if (e.getType() == ActiveMQExceptionType.DUPLICATE_METADATA) {
throw new InvalidClientIDException("clientID=" + clientID + " was already set into another connection");
@ -690,7 +698,7 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme
if (validateClientId) {
validateClientID(initialSession, clientID);
} 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 {
session.addMetaData(ClientSession.JMS_SESSION_IDENTIFIER_PROPERTY, "");
if (clientID != null) {
session.addMetaData(ClientSession.JMS_SESSION_CLIENT_ID_PROPERTY, clientID);
session.addMetaData(JMS_SESSION_CLIENT_ID_PROPERTY, clientID);
}
}

View File

@ -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.jms.ActiveMQJMSClient;
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.ActiveMQDestination;
import org.apache.activemq.artemis.ra.ActiveMQRABundle;
@ -492,7 +493,7 @@ public class ActiveMQActivation {
result.addMetaData(ClientSession.JMS_SESSION_IDENTIFIER_PROPERTY, "");
String clientID = ra.getClientID() == null ? spec.getClientID() : ra.getClientID();
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);

View File

@ -23,10 +23,10 @@ import javax.jms.InvalidClientIDException;
import javax.jms.JMSException;
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.server.ServerSession;
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.tests.util.JMSTestBase;
import org.junit.Test;
@ -49,7 +49,7 @@ public class SessionMetadataAddExceptionTest extends JMSTestBase {
public void beforeSessionMetadataAdded(ServerSession session, String key, String data)
throws ActiveMQException {
if (ClientSession.JMS_SESSION_CLIENT_ID_PROPERTY.equals(key)) {
if (ActiveMQConnection.JMS_SESSION_CLIENT_ID_PROPERTY.equals(key)) {
if ("invalid".equals(data)) {
throw new ActiveMQException("Invalid clientId");
}

View File

@ -1572,7 +1572,7 @@ public class ActiveMQServerControlTest extends ManagementTestBase {
JsonArray array = JsonUtil.readJsonArray(jsonString);
Assert.assertEquals(1 + (usingCore() ? 1 : 0), array.size());
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));
}