This closes #505

This commit is contained in:
Clebert Suconic 2016-05-04 16:53:25 -04:00
commit 99acd68838
7 changed files with 44 additions and 9 deletions

View File

@ -483,7 +483,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
public void runException() throws Exception {
checkBindings(bindings);
if (internalCreateQueue(queueName, selectorString, durable)) {
if (internalCreateQueue(queueName, selectorString, durable, autoCreated)) {
ActiveMQDestination destination = queues.get(queueName);
if (destination == null) {
@ -1047,6 +1047,13 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
private synchronized boolean internalCreateQueue(final String queueName,
final String selectorString,
final boolean durable) throws Exception {
return internalCreateQueue(queueName, selectorString, durable, false);
}
private synchronized boolean internalCreateQueue(final String queueName,
final String selectorString,
final boolean durable,
final boolean autoCreated) throws Exception {
if (queues.get(queueName) != null) {
return false;
}
@ -1060,7 +1067,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
coreFilterString = SelectorTranslator.convertToActiveMQFilterString(selectorString);
}
Queue queue = server.deployQueue(SimpleString.toSimpleString(activeMQQueue.getAddress()), SimpleString.toSimpleString(activeMQQueue.getAddress()), SimpleString.toSimpleString(coreFilterString), durable, false);
Queue queue = server.deployQueue(SimpleString.toSimpleString(activeMQQueue.getAddress()), SimpleString.toSimpleString(activeMQQueue.getAddress()), SimpleString.toSimpleString(coreFilterString), durable, false, autoCreated);
queues.put(queueName, activeMQQueue);

View File

@ -254,6 +254,13 @@ public interface ActiveMQServer extends ActiveMQComponent {
boolean durable,
boolean temporary) throws Exception;
Queue deployQueue(SimpleString address,
SimpleString queueName,
SimpleString filterString,
boolean durable,
boolean temporary,
boolean autoCreated) throws Exception;
Queue locateQueue(SimpleString queueName);
BindingQueryResult bindingQuery(SimpleString address) throws Exception;

View File

@ -1406,6 +1406,16 @@ public class ActiveMQServerImpl implements ActiveMQServer {
final SimpleString filterString,
final boolean durable,
final boolean temporary) throws Exception {
return deployQueue(address, resourceName, filterString, durable, temporary, false);
}
@Override
public Queue deployQueue(final SimpleString address,
final SimpleString resourceName,
final SimpleString filterString,
final boolean durable,
final boolean temporary,
final boolean autoCreated) throws Exception {
if (resourceName.toString().toLowerCase().startsWith("jms.topic")) {
ActiveMQServerLogger.LOGGER.deployTopic(resourceName);
@ -1414,7 +1424,7 @@ public class ActiveMQServerImpl implements ActiveMQServer {
ActiveMQServerLogger.LOGGER.deployQueue(resourceName);
}
return createQueue(address, resourceName, filterString, null, durable, temporary, true, false, false);
return createQueue(address, resourceName, filterString, null, durable, temporary, true, false, autoCreated);
}
@Override

View File

@ -108,7 +108,7 @@ public class RaceOnSyncLargeMessageOverReplicationTest extends ActiveMQTestBase
connection = (ActiveMQConnection) factory.createConnection();
session = connection.createSession(true, Session.SESSION_TRANSACTED);
queue = session.createQueue("jms.queue.Queue");
queue = session.createQueue("Queue");
producer = session.createProducer(queue);
}

View File

@ -119,6 +119,9 @@ public class GroupingTest extends JMSTestBase {
@Test
public void testGroupingWithJMS2Producer() throws Exception {
ConnectionFactory fact = getCF();
Assume.assumeFalse("only makes sense withOUT auto-group", ((ActiveMQConnectionFactory) fact).isAutoGroup());
Assume.assumeTrue("only makes sense withOUT explicit group-id", ((ActiveMQConnectionFactory) fact).getGroupID() == null);
final String groupID = UUID.randomUUID().toString();
JMSContext ctx = addContext(getCF().createContext(JMSContext.SESSION_TRANSACTED));

View File

@ -82,6 +82,10 @@ public class ActiveMQServerControlTest extends ManagementTestBase {
// Public --------------------------------------------------------
public boolean usingCore() {
return false;
}
@Test
public void testGetAttributes() throws Exception {
ActiveMQServerControl serverControl = createManagementControl();
@ -923,8 +927,8 @@ public class ActiveMQServerControlTest extends ManagementTestBase {
createSessionFactory(locator).close();
}
assertEquals(CONNECTION_COUNT, serverControl.getTotalConnectionCount());
assertEquals(0, serverControl.getConnectionCount());
assertEquals(CONNECTION_COUNT + (usingCore() ? 1 : 0), serverControl.getTotalConnectionCount());
assertEquals(0 + (usingCore() ? 1 : 0), serverControl.getConnectionCount());
locator.close();
}
@ -962,7 +966,7 @@ public class ActiveMQServerControlTest extends ManagementTestBase {
session.commit();
assertEquals(2, serverControl.getTotalMessagesAdded());
assertEquals(0, serverControl.getTotalMessageCount());
assertEquals(0 + (usingCore() ? 1 : 0), serverControl.getTotalMessageCount());
consumer1.close();
consumer2.close();
@ -1008,7 +1012,7 @@ public class ActiveMQServerControlTest extends ManagementTestBase {
session.commit();
assertEquals(2, serverControl.getTotalMessagesAcknowledged());
assertEquals(0, serverControl.getTotalMessageCount());
assertEquals(0 + (usingCore() ? 1 : 0), serverControl.getTotalMessageCount());
consumer1.close();
consumer2.close();
@ -1040,7 +1044,7 @@ public class ActiveMQServerControlTest extends ManagementTestBase {
ClientConsumer consumer1 = session.createConsumer(random1);
ClientConsumer consumer2 = session.createConsumer(random2);
assertEquals(2, serverControl.getTotalConsumerCount());
assertEquals(2 + (usingCore() ? 1 : 0), serverControl.getTotalConsumerCount());
assertEquals(1, queueControl1.getConsumerCount());
assertEquals(1, queueControl2.getConsumerCount());

View File

@ -664,6 +664,10 @@ public class ActiveMQServerControlUsingCoreTest extends ActiveMQServerControlTes
}
};
}
public boolean usingCore() {
return true;
}
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------