Author: jmesnil
Date: 2010-06-21 12:13:48 -0400 (Mon, 21 Jun 2010)
New Revision: 9348
Modified:
trunk/src/main/org/hornetq/api/jms/management/JMSServerControl.java
trunk/src/main/org/hornetq/jms/management/impl/JMSServerControlImpl.java
trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSServerControlTest.java
trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSServerControlUsingJMSTest.java
Log:
https://jira.jboss.org/browse/HORNETQ-422: Expose durable option on JMSServerControl for
createQueue
* add createQueue(..., boolean durable) method to JMSServerControl to let user create
non-durable JMS queues through management API
Modified: trunk/src/main/org/hornetq/api/jms/management/JMSServerControl.java
===================================================================
--- trunk/src/main/org/hornetq/api/jms/management/JMSServerControl.java 2010-06-21
12:15:34 UTC (rev 9347)
+++ trunk/src/main/org/hornetq/api/jms/management/JMSServerControl.java 2010-06-21
16:13:48 UTC (rev 9348)
@@ -60,7 +60,7 @@
// Operations ----------------------------------------------------
/**
- * Creates a JMS Queue.
+ * Creates a durable JMS Queue.
*
* @return {@code true} if the queue was created, {@code false} else
*/
@@ -68,7 +68,7 @@
boolean createQueue(@Parameter(name = "name", desc = "Name of the
queue to create") String name) throws Exception;
/**
- * Creates a JMS Queue with the specified name and JNDI binding.
+ * Creates a durable JMS Queue with the specified name and JNDI binding.
*
* @return {@code true} if the queue was created, {@code false} else
*/
@@ -77,7 +77,7 @@
@Parameter(name = "jndiBindings", desc =
"comma-separated list of JNDI bindings (use ',' if u need to use
commas in your jndi name)") String jndiBindings) throws Exception;
/**
- * Creates a JMS Queue with the specified name and JNDI binding.
+ * Creates a durable JMS Queue with the specified name, JNDI binding and selector.
*
* @return {@code true} if the queue was created, {@code false} else
*/
@@ -86,7 +86,18 @@
@Parameter(name = "jndiBindings", desc =
"comma-separated list of JNDI bindings (use ',' if u need to use
commas in your jndi name)") String jndiBindings,
@Parameter(name = "selector", desc = "the jms
selector") String selector) throws Exception;
+ /**
+ * Creates a JMS Queue with the specified name, durability, selector and JNDI
binding.
+ *
+ * @return {@code true} if the queue was created, {@code false} else
+ */
+ @Operation(desc = "Create a JMS Queue", impact =
MBeanOperationInfo.ACTION)
+ boolean createQueue(@Parameter(name = "name", desc = "Name of the
queue to create") String name,
+ @Parameter(name = "jndiBindings", desc =
"comma-separated list of JNDI bindings (use ',' if u need to use
commas in your jndi name)") String jndiBindings,
+ @Parameter(name = "selector", desc = "the jms
selector") String selector,
+ @Parameter(name = "durable", desc = "durability
of the queue") boolean durable) throws Exception;
+
/**
* Destroys a JMS Queue with the specified name.
*
Modified: trunk/src/main/org/hornetq/jms/management/impl/JMSServerControlImpl.java
===================================================================
--- trunk/src/main/org/hornetq/jms/management/impl/JMSServerControlImpl.java 2010-06-21
12:15:34 UTC (rev 9347)
+++ trunk/src/main/org/hornetq/jms/management/impl/JMSServerControlImpl.java 2010-06-21
16:13:48 UTC (rev 9348)
@@ -253,7 +253,7 @@
final String discoveryAddress,
final int discoveryPort,
final String jndiBindings) throws Exception
- {
+ {
checkStarted();
clearIO();
@@ -269,30 +269,32 @@
{
blockOnIO();
}
- }
+ }
-
- public boolean createQueue(@Parameter(name = "name", desc = "Name of
the queue to create") String name) throws Exception
+ public boolean createQueue(String name) throws Exception
{
- return createQueue(name, null, null);
+ return createQueue(name, null, null, true);
}
-
-
public boolean createQueue(final String name, final String jndiBindings) throws
Exception
{
- return createQueue(name, jndiBindings, null);
+ return createQueue(name, jndiBindings, null, true);
}
- public boolean createQueue(@Parameter(name = "name", desc = "Name of
the queue to create") String name, @Parameter(name = "jndiBindings", desc =
"comma-separated list of JNDI bindings (use ',' if u need to use
commas in your jndi name)") String jndiBindings, @Parameter(name =
"selector", desc = "the jms selector") String selector) throws
Exception
+ public boolean createQueue(String name, String jndiBindings, String selector) throws
Exception
{
+ return createQueue(name, jndiBindings, selector, true);
+ }
+
+ public boolean createQueue(String name, String jndiBindings, String selector, boolean
durable) throws Exception
+ {
checkStarted();
clearIO();
try
{
- boolean created = server.createQueue(true, name, selector, true,
JMSServerControlImpl.toArray(jndiBindings));
+ boolean created = server.createQueue(true, name, selector, durable,
JMSServerControlImpl.toArray(jndiBindings));
if (created)
{
sendNotification(NotificationType.QUEUE_CREATED, name);
@@ -326,7 +328,7 @@
}
}
- public boolean createTopic(@Parameter(name = "name", desc = "Name of
the topic to create") String name) throws Exception
+ public boolean createTopic(String name) throws Exception
{
return createTopic(name, null);
}
Modified:
trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSServerControlTest.java
===================================================================
---
trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSServerControlTest.java 2010-06-21
12:15:34 UTC (rev 9347)
+++
trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSServerControlTest.java 2010-06-21
16:13:48 UTC (rev 9348)
@@ -39,6 +39,7 @@
import org.hornetq.core.config.DiscoveryGroupConfiguration;
import org.hornetq.core.config.impl.ConfigurationImpl;
import org.hornetq.core.logging.Logger;
+import org.hornetq.core.postoffice.QueueBinding;
import org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory;
import org.hornetq.core.remoting.impl.invm.InVMConnectorFactory;
import org.hornetq.core.remoting.impl.invm.TransportConstants;
@@ -228,6 +229,30 @@
Assert.assertTrue(fakeJMSStorageManager.persistedJNDIMap.get(queueName).contains(bindings[2]));
}
+ public void testCreateNonDurableQueue() throws Exception
+ {
+ String queueName = RandomUtil.randomString();
+ String binding = RandomUtil.randomString();
+
+ UnitTestCase.checkNoBinding(context, binding);
+ checkNoResource(ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queueName));
+
+ JMSServerControl control = createManagementControl();
+ control.createQueue(queueName, binding, null, false);
+
+ Object o = UnitTestCase.checkBinding(context, binding);
+ Assert.assertTrue(o instanceof Queue);
+ Queue queue = (Queue)o;
+ Assert.assertEquals(queueName, queue.getQueueName());
+ QueueBinding queueBinding = (QueueBinding)server.getPostOffice().getBinding(new
SimpleString("jms.queue." + queueName));
+ assertFalse(queueBinding.getQueue().isDurable());
+ checkResource(ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queueName));
+
+ // queue is not durable => not stored
+ Assert.assertNull(fakeJMSStorageManager.destinationMap.get(queueName));
+ Assert.assertNull(fakeJMSStorageManager.persistedJNDIMap.get(queueName));
+ }
+
public void testDestroyQueue() throws Exception
{
String queueJNDIBinding = RandomUtil.randomString();
Modified:
trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSServerControlUsingJMSTest.java
===================================================================
---
trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSServerControlUsingJMSTest.java 2010-06-21
12:15:34 UTC (rev 9347)
+++
trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSServerControlUsingJMSTest.java 2010-06-21
16:13:48 UTC (rev 9348)
@@ -179,6 +179,11 @@
return (Boolean)proxy.invokeOperation("createQueue", name,
jndiBindings, selector);
}
+ public boolean createQueue(String name, String jndiBindings, String selector,
boolean durable) throws Exception
+ {
+ return (Boolean)proxy.invokeOperation("createQueue", name,
jndiBindings, selector, durable);
+ }
+
public boolean createTopic(final String name) throws Exception
{
return (Boolean)proxy.invokeOperation("createTopic", name);