This commit is contained in:
Michael Andre Pearce 2018-10-11 08:22:22 +01:00
commit d4ac3c2f87
3 changed files with 23 additions and 26 deletions

View File

@ -149,7 +149,7 @@
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-junit</artifactId>
<version>2.7.0-SNAPSHOT</version>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

View File

@ -97,20 +97,6 @@ public class DestAbstract extends ConnectionAbstract {
return new XMLMessageSerializer();
}
// FIXME We currently do not support producing to FQQN. This is a work around.
private ClientSession getManagementSession() throws Exception {
ServerLocator serverLocator = ActiveMQClient.createServerLocator(brokerURL);
ClientSessionFactory sf = serverLocator.createSessionFactory();
ClientSession managementSession;
if (user != null || password != null) {
managementSession = sf.createSession(user, password, false, true, true, false, 0);
} else {
managementSession = sf.createSession(false, true, true);
}
return managementSession;
}
public byte[] getQueueIdFromName(String queueName) throws Exception {
try {
ClientMessage message = getQueueAttribute(queueName, "ID");
@ -124,7 +110,14 @@ public class DestAbstract extends ConnectionAbstract {
}
protected ClientMessage getQueueAttribute(String queueName, String attribute) throws Exception {
ClientSession managementSession = getManagementSession();
try (ServerLocator serverLocator = ActiveMQClient.createServerLocator(brokerURL)) {
try (ClientSessionFactory sf = serverLocator.createSessionFactory()) {
ClientSession managementSession;
if (user != null || password != null) {
managementSession = sf.createSession(user, password, false, true, true, false, 0);
} else {
managementSession = sf.createSession(false, true, true);
}
managementSession.start();
try (ClientRequestor requestor = new ClientRequestor(managementSession, "activemq.management")) {
@ -137,6 +130,8 @@ public class DestAbstract extends ConnectionAbstract {
managementSession.stop();
}
}
}
}
protected String getQueueFromFQQN(String fqqn) {
return fqqn.substring(fqqn.indexOf(FQQN_SEPERATOR) + FQQN_SEPERATOR.length());

View File

@ -58,6 +58,7 @@ import static org.junit.Assert.assertTrue;
public class MessageSerializerTest extends CliTestBase {
private Connection connection;
private ActiveMQConnectionFactory cf;
@Before
@Override
@ -65,7 +66,7 @@ public class MessageSerializerTest extends CliTestBase {
setupAuth();
super.setup();
startServer();
ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("tcp://localhost:61616");
cf = new ActiveMQConnectionFactory("tcp://localhost:61616");
connection = cf.createConnection("admin", "admin");
}
@ -74,6 +75,7 @@ public class MessageSerializerTest extends CliTestBase {
public void tearDown() throws Exception {
try {
connection.close();
cf.close();
} finally {
stopServer();
super.tearDown();