[jboss-cvs] JBoss Messaging SVN: r5024 - in branches/Branch_1_4: integration/EAP4/tests-src/org/jboss/test/messaging/tools/container and 5 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Sep 25 00:52:34 EDT 2008
Author: gaohoward
Date: 2008-09-25 00:52:34 -0400 (Thu, 25 Sep 2008)
New Revision: 5024
Modified:
branches/Branch_1_4/integration/AS5/tests-src/org/jboss/test/messaging/tools/container/LocalTestServer.java
branches/Branch_1_4/integration/EAP4/tests-src/org/jboss/test/messaging/tools/container/LocalTestServer.java
branches/Branch_1_4/src/main/org/jboss/jms/server/destination/DestinationServiceSupport.java
branches/Branch_1_4/tests/etc/container.xml
branches/Branch_1_4/tests/src/org/jboss/test/messaging/jms/DLQTest.java
branches/Branch_1_4/tests/src/org/jboss/test/messaging/jms/ExpiryQueueTest.java
branches/Branch_1_4/tests/src/org/jboss/test/messaging/tools/ServerManagement.java
branches/Branch_1_4/tests/src/org/jboss/test/messaging/tools/container/RMITestServer.java
branches/Branch_1_4/tests/src/org/jboss/test/messaging/tools/container/Server.java
Log:
JBMESSAGING-1374
Modified: branches/Branch_1_4/integration/AS5/tests-src/org/jboss/test/messaging/tools/container/LocalTestServer.java
===================================================================
--- branches/Branch_1_4/integration/AS5/tests-src/org/jboss/test/messaging/tools/container/LocalTestServer.java 2008-09-24 23:08:48 UTC (rev 5023)
+++ branches/Branch_1_4/integration/AS5/tests-src/org/jboss/test/messaging/tools/container/LocalTestServer.java 2008-09-25 04:52:34 UTC (rev 5024)
@@ -1,24 +1,14 @@
/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
+ * JBoss, Home of Professional Open Source Copyright 2005, JBoss Inc., and individual contributors as indicated by the
+ * @authors tag. See the copyright.txt in the distribution for a full listing of individual contributors. This is free
+ * software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+ * This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details. You should have received a copy of the GNU Lesser General Public License along with this software; if not,
+ * write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
+ */
package org.jboss.test.messaging.tools.container;
import org.jboss.aop.AspectXmlLoader;
@@ -51,9 +41,7 @@
/**
* @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>1.1</tt>
- *
- * LocalTestServer.java,v 1.1 2006/02/21 08:25:32 timfox Exp
+ * @version <tt>1.1</tt> LocalTestServer.java,v 1.1 2006/02/21 08:25:32 timfox Exp
*/
public class LocalTestServer implements Server
{
@@ -77,9 +65,11 @@
private ServiceContainer sc;
- // service dependencies
+ // service dependencies
private ObjectName persistenceManagerObjectName;
+
private ObjectName postOfficeObjectName;
+
private ObjectName jmsUserManagerObjectName;
// the server MBean itself
@@ -108,8 +98,7 @@
return serverIndex;
}
- public void start(String containerConfig,
- boolean clearDatabase) throws Exception
+ public void start(String containerConfig, boolean clearDatabase) throws Exception
{
start(containerConfig, null, clearDatabase, true);
}
@@ -184,7 +173,6 @@
return true;
}
-
public void ping() throws Exception
{
// noop... do nothing
@@ -217,20 +205,17 @@
sc.setAttribute(on, name, valueAsString);
}
- public Object invoke(ObjectName on, String operationName, Object[] params, String[] signature)
- throws Exception
+ public Object invoke(ObjectName on, String operationName, Object[] params, String[] signature) throws Exception
{
return sc.invoke(on, operationName, params, signature);
}
- public void addNotificationListener(ObjectName on, NotificationListener listener)
- throws Exception
+ public void addNotificationListener(ObjectName on, NotificationListener listener) throws Exception
{
sc.addNotificationListener(on, listener);
}
- public void removeNotificationListener(ObjectName on, NotificationListener listener)
- throws Exception
+ public void removeNotificationListener(ObjectName on, NotificationListener listener) throws Exception
{
sc.removeNotificationListener(on, listener);
}
@@ -289,7 +274,7 @@
ServiceAttributeOverrides attrOverrides,
boolean clustered) throws Exception
{
- List toStop = new ArrayList();
+ List toStop = new ArrayList();
try
{
log.debug("creating ServerPeer instance");
@@ -298,68 +283,70 @@
// src/etc/server/default/deploy. This will allow to test the default parameters we ship.
String mainConfigFile = "server/default/deploy/messaging-service.xml";
-
+
String persistenceConfigFile = sc.getPersistenceConfigFile(clustered);
log.info(" Persistence config file .. " + persistenceConfigFile);
ServiceDeploymentDescriptor mdd = ServiceConfigHelper.loadConfigFile(mainConfigFile);
-
+
ServiceDeploymentDescriptor pdd = ServiceConfigHelper.loadConfigFile(persistenceConfigFile);
- MBeanConfigurationElement persistenceManagerConfig =
- ServiceConfigHelper.getServiceConfiguration(pdd, "PersistenceManager");
+ MBeanConfigurationElement persistenceManagerConfig = ServiceConfigHelper.getServiceConfiguration(pdd,
+ "PersistenceManager");
persistenceManagerObjectName = sc.registerAndConfigureService(persistenceManagerConfig);
overrideAttributes(persistenceManagerObjectName, attrOverrides);
toStop.add(persistenceManagerObjectName);
sc.invoke(persistenceManagerObjectName, "create", new Object[0], new String[0]);
- sc.invoke(persistenceManagerObjectName, "start", new Object[0], new String[0]);
+ sc.invoke(persistenceManagerObjectName, "start", new Object[0], new String[0]);
- MBeanConfigurationElement jmsUserManagerConfig =
- ServiceConfigHelper.getServiceConfiguration(pdd, "JMSUserManager");
+ MBeanConfigurationElement jmsUserManagerConfig = ServiceConfigHelper.getServiceConfiguration(pdd,
+ "JMSUserManager");
jmsUserManagerObjectName = sc.registerAndConfigureService(jmsUserManagerConfig);
- overrideAttributes(jmsUserManagerObjectName, attrOverrides);
+ overrideAttributes(jmsUserManagerObjectName, attrOverrides);
toStop.add(jmsUserManagerObjectName);
sc.invoke(jmsUserManagerObjectName, "create", new Object[0], new String[0]);
sc.invoke(jmsUserManagerObjectName, "start", new Object[0], new String[0]);
- //regioster metadatasore
- /* MBeanConfigurationElement securityStoreConfig =
- ServiceConfigHelper.getServiceConfiguration(mdd, "SecurityStore");
- securityStoreObjectname = sc.registerAndConfigureService(securityStoreConfig);
- toStop.add(securityStoreObjectname);*/
+ // regioster metadatasore
+ /*
+ * MBeanConfigurationElement securityStoreConfig = ServiceConfigHelper.getServiceConfiguration(mdd,
+ * "SecurityStore"); securityStoreObjectname = sc.registerAndConfigureService(securityStoreConfig);
+ * toStop.add(securityStoreObjectname);
+ */
// register server peer as a service, dependencies are injected automatically
- MBeanConfigurationElement serverPeerConfig =
- ServiceConfigHelper.getServiceConfiguration(mdd, "ServerPeer");
+ MBeanConfigurationElement serverPeerConfig = ServiceConfigHelper.getServiceConfiguration(mdd, "ServerPeer");
// overwrite the file configuration, if needed
- overrideServerPeerConfiguration(serverPeerConfig, serverPeerID, defaultQueueJNDIContext,
- defaultTopicJNDIContext);
+ overrideServerPeerConfiguration(serverPeerConfig,
+ serverPeerID,
+ defaultQueueJNDIContext,
+ defaultTopicJNDIContext);
serverPeerObjectName = sc.registerAndConfigureService(serverPeerConfig);
overrideAttributes(serverPeerObjectName, attrOverrides);
- //ServerPeer serverPeer = (ServerPeer) sc.getMBeanServer().
+ // ServerPeer serverPeer = (ServerPeer) sc.getMBeanServer().
log.debug("starting JMS server");
toStop.add(serverPeerObjectName);
- sc.getMBeanServer().setAttribute(serverPeerObjectName, new Attribute("SecurityStore", sc.startSecurityStore()));
+ sc.getMBeanServer()
+ .setAttribute(serverPeerObjectName, new Attribute("SecurityStore", sc.startSecurityStore()));
sc.invoke(serverPeerObjectName, "create", new Object[0], new String[0]);
sc.invoke(serverPeerObjectName, "start", new Object[0], new String[0]);
- MBeanConfigurationElement postOfficeConfig =
- ServiceConfigHelper.getServiceConfiguration(pdd, "PostOffice");
+ MBeanConfigurationElement postOfficeConfig = ServiceConfigHelper.getServiceConfiguration(pdd, "PostOffice");
- postOfficeObjectName = sc.registerAndConfigureService(postOfficeConfig);
- sc.setAttribute(postOfficeObjectName, "Clustered", clustered ? "true" : "false");
-
+ postOfficeObjectName = sc.registerAndConfigureService(postOfficeConfig);
+ sc.setAttribute(postOfficeObjectName, "Clustered", clustered ? "true" : "false");
+
overrideAttributes(postOfficeObjectName, attrOverrides);
toStop.add(postOfficeObjectName);
sc.invoke(postOfficeObjectName, "create", new Object[0], new String[0]);
- sc.invoke(postOfficeObjectName, "start", new Object[0], new String[0]);
+ sc.invoke(postOfficeObjectName, "start", new Object[0], new String[0]);
log.debug("deploying connection factories");
sc.startConnectionFactories(attrOverrides);
@@ -367,21 +354,21 @@
catch (Exception e)
{
log.error("Failed to start", e);
-
- //Now we need to shutdown any services we did start
+
+ // Now we need to shutdown any services we did start
for (int i = toStop.size() - 1; i >= 0; i--)
{
- ObjectName on = (ObjectName)toStop.get(i);
- log.info("stopping: " + on);
- try
- {
- sc.unregisterService(on);
- }
- catch (Exception ignore)
- {
- }
+ ObjectName on = (ObjectName)toStop.get(i);
+ log.info("stopping: " + on);
+ try
+ {
+ sc.unregisterService(on);
+ }
+ catch (Exception ignore)
+ {
+ }
}
-
+
throw e;
}
}
@@ -416,36 +403,36 @@
try
{
- Set destinations = (Set)sc.getAttribute(serverPeerObjectName, "Destinations");
-
- for(Iterator i = destinations.iterator(); i.hasNext(); )
- {
- String name;
- boolean isQueue = true;
- Destination d = (Destination)i.next();
- if (d instanceof Queue)
- {
- name = ((Queue)d).getQueueName();
- }
- else
- {
- isQueue = false;
- name = ((Topic)d).getTopicName();
- }
-
- try
- {
- undeployDestination(isQueue, name);
- }
- catch (Exception e)
- {
- //needs to be resilient
- }
- }
+ Set destinations = (Set)sc.getAttribute(serverPeerObjectName, "Destinations");
+
+ for (Iterator i = destinations.iterator(); i.hasNext();)
+ {
+ String name;
+ boolean isQueue = true;
+ Destination d = (Destination)i.next();
+ if (d instanceof Queue)
+ {
+ name = ((Queue)d).getQueueName();
+ }
+ else
+ {
+ isQueue = false;
+ name = ((Topic)d).getTopicName();
+ }
+
+ try
+ {
+ undeployDestination(isQueue, name);
+ }
+ catch (Exception e)
+ {
+ // needs to be resilient
+ }
+ }
}
catch (Exception ignore)
{
- //Needs to be resilient on close
+ // Needs to be resilient on close
}
log.debug("stopping JMS server");
@@ -460,10 +447,10 @@
}
catch (Exception ignore)
{
- //If the serverpeer failed when starting up previously, then only some of the
- //services may be started. The ones that didn't start will fail when attempting to shut
- //them down.
- //Hence we must catch and ignore or we won't shut everything down
+ // If the serverpeer failed when starting up previously, then only some of the
+ // services may be started. The ones that didn't start will fail when attempting to shut
+ // them down.
+ // Hence we must catch and ignore or we won't shut everything down
}
log.debug("stopping ServerPeer's plug-in dependencies");
@@ -476,10 +463,10 @@
}
catch (Exception ignore)
{
- //If the serverpeer failed when starting up previously, then only some of the
- //services may be started. The ones that didn't start will fail when attempting to shut
- //them down.
- //Hence we must catch and ignore or we won't shut everything down
+ // If the serverpeer failed when starting up previously, then only some of the
+ // services may be started. The ones that didn't start will fail when attempting to shut
+ // them down.
+ // Hence we must catch and ignore or we won't shut everything down
}
try
@@ -490,10 +477,10 @@
}
catch (Exception ignore)
{
- //If the serverpeer failed when starting up previously, then only some of the
- //services may be started. The ones that didn't start will fail when attempting to shut
- //them down.
- //Hence we must catch and ignore or we won't shut everything down
+ // If the serverpeer failed when starting up previously, then only some of the
+ // services may be started. The ones that didn't start will fail when attempting to shut
+ // them down.
+ // Hence we must catch and ignore or we won't shut everything down
}
try
@@ -504,10 +491,10 @@
}
catch (Exception ignore)
{
- //If the serverpeer failed when starting up previously, then only some of the
- //services may be started. The ones that didn't start will fail when attempting to shut
- //them down.
- //Hence we must catch and ignore or we won't shut everything down
+ // If the serverpeer failed when starting up previously, then only some of the
+ // services may be started. The ones that didn't start will fail when attempting to shut
+ // them down.
+ // Hence we must catch and ignore or we won't shut everything down
}
}
catch (Exception e)
@@ -535,25 +522,21 @@
public Set getConnectorSubsystems() throws Exception
{
- RemotingJMXWrapper remoting =
- (RemotingJMXWrapper)sc.getService(ServiceContainer.REMOTING_OBJECT_NAME);
+ RemotingJMXWrapper remoting = (RemotingJMXWrapper)sc.getService(ServiceContainer.REMOTING_OBJECT_NAME);
return remoting.getConnectorSubsystems();
}
- public void addServerInvocationHandler(String subsystem, ServerInvocationHandler handler)
- throws Exception
+ public void addServerInvocationHandler(String subsystem, ServerInvocationHandler handler) throws Exception
{
- RemotingJMXWrapper remoting =
- (RemotingJMXWrapper)sc.getService(ServiceContainer.REMOTING_OBJECT_NAME);
+ RemotingJMXWrapper remoting = (RemotingJMXWrapper)sc.getService(ServiceContainer.REMOTING_OBJECT_NAME);
remoting.addInvocationHandler(subsystem, handler);
}
public void removeServerInvocationHandler(String subsystem) throws Exception
{
- RemotingJMXWrapper remoting =
- (RemotingJMXWrapper)sc.getService(ServiceContainer.REMOTING_OBJECT_NAME);
+ RemotingJMXWrapper remoting = (RemotingJMXWrapper)sc.getService(ServiceContainer.REMOTING_OBJECT_NAME);
remoting.removeInvocationHandler(subsystem);
}
@@ -584,8 +567,7 @@
*/
public ServerPeer getServerPeer() throws Exception
{
- return (ServerPeer)sc.
- getAttribute(serverPeerObjectName, "Instance");
+ return (ServerPeer)sc.getAttribute(serverPeerObjectName, "Instance");
}
public void deployTopic(String name, String jndiName, boolean clustered) throws Exception
@@ -593,17 +575,22 @@
deployDestination(false, name, jndiName, clustered);
}
- public void deployTopic(String name, String jndiName, int fullSize, int pageSize,
- int downCacheSize, boolean clustered) throws Exception
+ public void deployTopic(String name,
+ String jndiName,
+ int fullSize,
+ int pageSize,
+ int downCacheSize,
+ boolean clustered) throws Exception
{
deployDestination(false, name, jndiName, fullSize, pageSize, downCacheSize, clustered);
}
public void deployTopicProgrammatically(String name, String jndiName) throws Exception
{
- sc.invoke(serverPeerObjectName, "deployTopic",
+ sc.invoke(serverPeerObjectName,
+ "deployTopic",
new Object[] { name, jndiName },
- new String[] { "java.lang.String", "java.lang.String"} );
+ new String[] { "java.lang.String", "java.lang.String" });
}
public void deployQueue(String name, String jndiName, boolean clustered) throws Exception
@@ -611,32 +598,142 @@
deployDestination(true, name, jndiName, clustered);
}
- public void deployQueue(String name, String jndiName, int fullSize, int pageSize,
- int downCacheSize, boolean clustered) throws Exception
+ public void deployQueue(String name,
+ String jndiName,
+ int fullSize,
+ int pageSize,
+ int downCacheSize,
+ boolean clustered) throws Exception
{
deployDestination(true, name, jndiName, fullSize, pageSize, downCacheSize, clustered);
}
public void deployQueueProgrammatically(String name, String jndiName) throws Exception
{
- sc.invoke(serverPeerObjectName, "deployQueue",
+ sc.invoke(serverPeerObjectName,
+ "deployQueue",
new Object[] { name, jndiName },
- new String[] { "java.lang.String", "java.lang.String"} );
+ new String[] { "java.lang.String", "java.lang.String" });
}
+ public ObjectName deployQueueWithDLQnExpiryQ(String q, String dlq, String expq) throws Exception
+ {
+ String config = "<mbean code=\"org.jboss.jms.server.destination." + "QueueService" +
+ "\"" +
+ " name=\"jboss.messaging.destination:service=" +
+ "Queue" +
+ ",name=" +
+ q +
+ "\"" +
+ " xmbean-dd=\"xmdesc/" +
+ "Queue" +
+ "-xmbean.xml\">" +
+ " <depends optional-attribute-name=\"ServerPeer\">jboss.messaging:service=ServerPeer</depends>" +
+ " <depends>jboss.messaging:service=PostOffice</depends>" +
+ " <attribute name=\"DLQ\">" +
+ "jboss.messaging.destination:service=Queue,name=" +
+ dlq +
+ "</attribute>" +
+ " <attribute name=\"ExpiryQueue\">" +
+ "jboss.messaging.destination:service=Queue,name=" +
+ expq +
+ "</attribute>" +
+ "</mbean>";
+
+ MBeanConfigurationElement mbean = new MBeanConfigurationElement(XMLUtil.stringToElement(config));
+ ObjectName deston = sc.registerAndConfigureService(mbean);
+ sc.invoke(deston, "create", new Object[0], new String[0]);
+ // sc.invoke(deston, "start", new Object[0], new String[0]);
+ return deston;
+ }
+
+ public ObjectName deployTopicWithDLQnExpiryQ(String topic, String dlq, String expq) throws Exception
+ {
+ String config = "<mbean code=\"org.jboss.jms.server.destination." + "TopicService" +
+ "\"" +
+ " name=\"jboss.messaging.destination:service=" +
+ "Topic" +
+ ",name=" +
+ topic +
+ "\"" +
+ " xmbean-dd=\"xmdesc/" +
+ "Topic" +
+ "-xmbean.xml\">" +
+ " <depends optional-attribute-name=\"ServerPeer\">jboss.messaging:service=ServerPeer</depends>" +
+ " <depends>jboss.messaging:service=PostOffice</depends>" +
+ " <attribute name=\"DLQ\">" +
+ "jboss.messaging.destination:service=Queue,name=" +
+ dlq +
+ "</attribute>" +
+ " <attribute name=\"ExpiryQueue\">" +
+ "jboss.messaging.destination:service=Queue,name=" +
+ expq +
+ "</attribute>" +
+ "</mbean>";
+
+ MBeanConfigurationElement mbean = new MBeanConfigurationElement(XMLUtil.stringToElement(config));
+ ObjectName deston = sc.registerAndConfigureService(mbean);
+ sc.invoke(deston, "create", new Object[0], new String[0]);
+ return deston;
+ }
+
+ public ObjectName deployQueueWithoutStart(String q, String jndiName, boolean b) throws Exception
+ {
+ String config = "<mbean code=\"org.jboss.jms.server.destination." + "QueueService" +
+ "\"" +
+ " name=\"jboss.messaging.destination:service=" +
+ "Queue" +
+ ",name=" +
+ q +
+ "\"" +
+ " xmbean-dd=\"xmdesc/" +
+ "Queue" +
+ "-xmbean.xml\">" +
+ (jndiName != null ? " <attribute name=\"JNDIName\">" + jndiName + "</attribute>" : "") +
+ " <depends optional-attribute-name=\"ServerPeer\">jboss.messaging:service=ServerPeer</depends>" +
+ " <depends>jboss.messaging:service=PostOffice</depends>" +
+ " <attribute name=\"Clustered\">" +
+ String.valueOf(b) +
+ "</attribute>" +
+ "</mbean>";
+
+ MBeanConfigurationElement mbean = new MBeanConfigurationElement(XMLUtil.stringToElement(config));
+ ObjectName deston = sc.registerAndConfigureService(mbean);
+ sc.invoke(deston, "create", new Object[0], new String[0]);
+ return deston;
+ }
+
+ /**
+ * start the services.
+ */
+ public void startDestinationService(ObjectName[] objectNames) throws Exception
+ {
+ for (ObjectName sv : objectNames)
+ {
+ sc.invoke(sv, "start", new Object[0], new String[0]);
+ }
+ }
+
public void deployDestination(boolean isQueue, String name, String jndiName, boolean clustered) throws Exception
{
- String config =
- "<mbean code=\"org.jboss.jms.server.destination." + (isQueue ? "QueueService" : "TopicService") + "\"" +
- " name=\"jboss.messaging.destination:service=" + (isQueue ? "Queue" : "Topic") + ",name=" + name + "\"" +
- " xmbean-dd=\"xmdesc/" + (isQueue ? "Queue" : "Topic" ) + "-xmbean.xml\">" +
- (jndiName != null ? " <attribute name=\"JNDIName\">" + jndiName + "</attribute>" : "") +
- " <depends optional-attribute-name=\"ServerPeer\">jboss.messaging:service=ServerPeer</depends>" +
- " <attribute name=\"Clustered\">" + String.valueOf(clustered) + "</attribute>" +
- "</mbean>";
+ String config = "<mbean code=\"org.jboss.jms.server.destination." + (isQueue ? "QueueService" : "TopicService") +
+ "\"" +
+ " name=\"jboss.messaging.destination:service=" +
+ (isQueue ? "Queue" : "Topic") +
+ ",name=" +
+ name +
+ "\"" +
+ " xmbean-dd=\"xmdesc/" +
+ (isQueue ? "Queue" : "Topic") +
+ "-xmbean.xml\">" +
+ (jndiName != null ? " <attribute name=\"JNDIName\">" + jndiName + "</attribute>" : "") +
+ " <depends optional-attribute-name=\"ServerPeer\">jboss.messaging:service=ServerPeer</depends>" +
+ " <attribute name=\"Clustered\">" +
+ String.valueOf(clustered) +
+ "</attribute>" +
+ "</mbean>";
- MBeanConfigurationElement mbean =
- new MBeanConfigurationElement(XMLUtil.stringToElement(config));
+ MBeanConfigurationElement mbean = new MBeanConfigurationElement(XMLUtil.stringToElement(config));
ObjectName deston = sc.registerAndConfigureService(mbean);
sc.invoke(deston, "create", new Object[0], new String[0]);
sc.invoke(deston, "start", new Object[0], new String[0]);
@@ -652,20 +749,33 @@
{
log.info("deploying queue, fullsize:" + fullSize + ", ps:" + pageSize + " dc size:" + downCacheSize);
- String config =
- "<mbean code=\"org.jboss.jms.server.destination." + (isQueue ? "QueueService" : "TopicService") + "\"" +
- " name=\"jboss.messaging.destination:service=" + (isQueue ? "Queue" : "Topic") + ",name=" + name + "\"" +
- " xmbean-dd=\"xmdesc/" + (isQueue ? "Queue" : "Topic" ) + "-xmbean.xml\">" +
- (jndiName != null ? " <attribute name=\"JNDIName\">" + jndiName + "</attribute>" : "") +
- " <depends optional-attribute-name=\"ServerPeer\">jboss.messaging:service=ServerPeer</depends>" +
- " <attribute name=\"FullSize\">" + fullSize + "</attribute>" +
- " <attribute name=\"PageSize\">" + pageSize + "</attribute>" +
- " <attribute name=\"DownCacheSize\">" + downCacheSize + "</attribute>" +
- " <attribute name=\"Clustered\">" + String.valueOf(clustered) + "</attribute>" +
- "</mbean>";
+ String config = "<mbean code=\"org.jboss.jms.server.destination." + (isQueue ? "QueueService" : "TopicService") +
+ "\"" +
+ " name=\"jboss.messaging.destination:service=" +
+ (isQueue ? "Queue" : "Topic") +
+ ",name=" +
+ name +
+ "\"" +
+ " xmbean-dd=\"xmdesc/" +
+ (isQueue ? "Queue" : "Topic") +
+ "-xmbean.xml\">" +
+ (jndiName != null ? " <attribute name=\"JNDIName\">" + jndiName + "</attribute>" : "") +
+ " <depends optional-attribute-name=\"ServerPeer\">jboss.messaging:service=ServerPeer</depends>" +
+ " <attribute name=\"FullSize\">" +
+ fullSize +
+ "</attribute>" +
+ " <attribute name=\"PageSize\">" +
+ pageSize +
+ "</attribute>" +
+ " <attribute name=\"DownCacheSize\">" +
+ downCacheSize +
+ "</attribute>" +
+ " <attribute name=\"Clustered\">" +
+ String.valueOf(clustered) +
+ "</attribute>" +
+ "</mbean>";
- MBeanConfigurationElement mbean =
- new MBeanConfigurationElement(XMLUtil.stringToElement(config));
+ MBeanConfigurationElement mbean = new MBeanConfigurationElement(XMLUtil.stringToElement(config));
ObjectName deston = sc.registerAndConfigureService(mbean);
sc.invoke(deston, "create", new Object[0], new String[0]);
sc.invoke(deston, "start", new Object[0], new String[0]);
@@ -673,8 +783,7 @@
public void undeployDestination(boolean isQueue, String name) throws Exception
{
- ObjectName pattern =
- new ObjectName("*:service=" + (isQueue ? "Queue" : "Topic") + ",name=" + name);
+ ObjectName pattern = new ObjectName("*:service=" + (isQueue ? "Queue" : "Topic") + ",name=" + name);
Set s = sc.query(pattern);
int size = s.size();
if (size == 0)
@@ -696,90 +805,116 @@
{
if (isQueue)
{
- return ((Boolean)sc.invoke(serverPeerObjectName, "undeployQueue",
+ return ((Boolean)sc.invoke(serverPeerObjectName,
+ "undeployQueue",
new Object[] { name },
- new String[] { "java.lang.String"})).booleanValue();
+ new String[] { "java.lang.String" })).booleanValue();
}
else
{
- return ((Boolean)sc.invoke(serverPeerObjectName, "undeployTopic",
+ return ((Boolean)sc.invoke(serverPeerObjectName,
+ "undeployTopic",
new Object[] { name },
- new String[] { "java.lang.String"})).booleanValue();
+ new String[] { "java.lang.String" })).booleanValue();
}
}
- public void deployConnectionFactory(String objectName,
- String[] jndiBindings,
- int prefetchSize) throws Exception
+ public void deployConnectionFactory(String objectName, String[] jndiBindings, int prefetchSize) throws Exception
{
deployConnectionFactory(objectName, jndiBindings, prefetchSize, -1, -1, -1, false, false, false, null);
}
- public void deployConnectionFactory(String objectName,
- String[] jndiBindings) throws Exception
+ public void deployConnectionFactory(String objectName, String[] jndiBindings) throws Exception
{
deployConnectionFactory(objectName, jndiBindings, -1, -1, -1, -1, false, false, false, null);
}
-
- public void deployConnectionFactory(String objectName, String[] jndiBindings, boolean strictTck) throws Exception
- {
- deployConnectionFactory(objectName, jndiBindings, -1, -1, -1, -1, false, false, strictTck, null);
- }
-
- public void deployConnectionFactory(String objectName,
- String[] jndiBindings,
- int prefetchSize,
- int defaultTempQueueFullSize,
- int defaultTempQueuePageSize,
- int defaultTempQueueDownCacheSize) throws Exception
+ public void deployConnectionFactory(String objectName, String[] jndiBindings, boolean strictTck) throws Exception
{
- this.deployConnectionFactory(objectName, jndiBindings, prefetchSize, defaultTempQueueFullSize,
- defaultTempQueuePageSize, defaultTempQueueDownCacheSize, false, false, false, null);
+ deployConnectionFactory(objectName, jndiBindings, -1, -1, -1, -1, false, false, strictTck, null);
}
-
+
public void deployConnectionFactory(String objectName,
- String[] jndiBindings,
- boolean supportsFailover, boolean supportsLoadBalancing) throws Exception
+ String[] jndiBindings,
+ int prefetchSize,
+ int defaultTempQueueFullSize,
+ int defaultTempQueuePageSize,
+ int defaultTempQueueDownCacheSize) throws Exception
{
- this.deployConnectionFactory(objectName, jndiBindings, -1, -1,
- -1, -1, supportsFailover, supportsLoadBalancing, false, null);
+ this.deployConnectionFactory(objectName,
+ jndiBindings,
+ prefetchSize,
+ defaultTempQueueFullSize,
+ defaultTempQueuePageSize,
+ defaultTempQueueDownCacheSize,
+ false,
+ false,
+ false,
+ null);
}
-
+
public void deployConnectionFactory(String objectName,
- String[] jndiBindings,
- boolean supportsFailover, boolean supportsLoadBalancing, String clientID) throws Exception
+ String[] jndiBindings,
+ boolean supportsFailover,
+ boolean supportsLoadBalancing) throws Exception
{
- this.deployConnectionFactory(objectName, jndiBindings, -1, -1,
- -1, -1, supportsFailover, supportsLoadBalancing, false, clientID);
+ this.deployConnectionFactory(objectName,
+ jndiBindings,
+ -1,
+ -1,
+ -1,
+ -1,
+ supportsFailover,
+ supportsLoadBalancing,
+ false,
+ null);
}
- private void deployConnectionFactory(String objectName,
+ public void deployConnectionFactory(String objectName,
String[] jndiBindings,
- int prefetchSize,
- int defaultTempQueueFullSize,
- int defaultTempQueuePageSize,
- int defaultTempQueueDownCacheSize,
boolean supportsFailover,
boolean supportsLoadBalancing,
- boolean strictTck,
String clientID) throws Exception
{
+ this.deployConnectionFactory(objectName,
+ jndiBindings,
+ -1,
+ -1,
+ -1,
+ -1,
+ supportsFailover,
+ supportsLoadBalancing,
+ false,
+ clientID);
+ }
+
+ private void deployConnectionFactory(String objectName,
+ String[] jndiBindings,
+ int prefetchSize,
+ int defaultTempQueueFullSize,
+ int defaultTempQueuePageSize,
+ int defaultTempQueueDownCacheSize,
+ boolean supportsFailover,
+ boolean supportsLoadBalancing,
+ boolean strictTck,
+ String clientID) throws Exception
+ {
log.trace("deploying connection factory with name: " + objectName);
-
- String config =
- "<mbean code=\"org.jboss.jms.server.connectionfactory.ConnectionFactory\"\n" +
- "name=\"" + objectName + "\"\n" +
- "xmbean-dd=\"xmdesc/ConnectionFactory-xmbean.xml\">\n" +
- "<depends optional-attribute-name=\"ServerPeer\">jboss.messaging:service=ServerPeer</depends>\n" +
- "<depends optional-attribute-name=\"Connector\">" + ServiceContainer.REMOTING_OBJECT_NAME +
- "</depends>\n";
-//<arg type="java.lang.String" value="MyClientID"/>
+
+ String config = "<mbean code=\"org.jboss.jms.server.connectionfactory.ConnectionFactory\"\n" + "name=\"" +
+ objectName +
+ "\"\n" +
+ "xmbean-dd=\"xmdesc/ConnectionFactory-xmbean.xml\">\n" +
+ "<depends optional-attribute-name=\"ServerPeer\">jboss.messaging:service=ServerPeer</depends>\n" +
+ "<depends optional-attribute-name=\"Connector\">" +
+ ServiceContainer.REMOTING_OBJECT_NAME +
+ "</depends>\n";
+ // <arg type="java.lang.String" value="MyClientID"/>
if (clientID != null)
{
config += "<constructor><arg type=\"java.lang.String\" value=\"" + clientID + "\"/> </constructor>\n";
}
-
+
if (defaultTempQueueFullSize != -1)
{
config += "<attribute name=\"DefaultTempQueueFullSize\">" + defaultTempQueueFullSize + "</attribute>\n";
@@ -792,35 +927,35 @@
if (defaultTempQueueDownCacheSize != -1)
{
- config += "<attribute name=\"DefaultTempQueueDownCacheSize\">" + defaultTempQueueDownCacheSize + "</attribute>\n";
+ config += "<attribute name=\"DefaultTempQueueDownCacheSize\">" + defaultTempQueueDownCacheSize +
+ "</attribute>\n";
}
if (prefetchSize != -1)
{
config += "<attribute name=\"PrefetchSize\">" + prefetchSize + "</attribute>";
}
-
+
config += "<attribute name=\"SupportsFailover\">" + supportsFailover + "</attribute>";
config += "<attribute name=\"SupportsLoadBalancing\">" + supportsLoadBalancing + "</attribute>";
config += "<attribute name=\"StrictTck\">" + strictTck + "</attribute>";
if (jndiBindings != null)
{
- config += "<attribute name=\"JNDIBindings\"><bindings>";
-
- for (int i = 0; i < jndiBindings.length; i++)
- {
- config += "<binding>" + jndiBindings[i] + "</binding>\n";
- }
- config += "</bindings></attribute>";
+ config += "<attribute name=\"JNDIBindings\"><bindings>";
+
+ for (int i = 0; i < jndiBindings.length; i++)
+ {
+ config += "<binding>" + jndiBindings[i] + "</binding>\n";
+ }
+ config += "</bindings></attribute>";
}
config += "</mbean>";
MBeanConfigurationElement mc = new MBeanConfigurationElement(XMLUtil.stringToElement(config));
ObjectName on = sc.registerAndConfigureService(mc);
-
-
+
log.trace("Object name is now: " + on);
-
+
sc.invoke(on, "create", new Object[0], new String[0]);
sc.invoke(on, "start", new Object[0], new String[0]);
}
@@ -835,14 +970,14 @@
public void configureSecurityForDestination(String destName, String config) throws Exception
{
Set s = sc.query(new ObjectName("*:service=Queue,name=" + destName));
- for(Iterator i = s.iterator(); i.hasNext();)
+ for (Iterator i = s.iterator(); i.hasNext();)
{
ObjectName on = (ObjectName)i.next();
sc.setAttribute(on, "SecurityConfig", config);
}
s = sc.query(new ObjectName("*:service=Topic,name=" + destName));
- for(Iterator i = s.iterator(); i.hasNext();)
+ for (Iterator i = s.iterator(); i.hasNext();)
{
ObjectName on = (ObjectName)i.next();
sc.setAttribute(on, "SecurityConfig", config);
@@ -872,63 +1007,62 @@
public Set getNodeIDView() throws Exception
{
- PostOffice postOffice = (PostOffice)sc.getAttribute(postOfficeObjectName, "Instance");
-
- return postOffice.nodeIDView();
+ PostOffice postOffice = (PostOffice)sc.getAttribute(postOfficeObjectName, "Instance");
+
+ return postOffice.nodeIDView();
}
-
+
public Map getFailoverMap() throws Exception
{
- PostOffice postOffice = (PostOffice)sc.getAttribute(postOfficeObjectName, "Instance");
-
- return postOffice.getFailoverMap();
+ PostOffice postOffice = (PostOffice)sc.getAttribute(postOfficeObjectName, "Instance");
+
+ return postOffice.getFailoverMap();
}
-
+
public Map getRecoveryArea(String queueName) throws Exception
{
- PostOffice postOffice = (PostOffice)sc.getAttribute(postOfficeObjectName, "Instance");
-
- return postOffice.getRecoveryArea(queueName);
+ PostOffice postOffice = (PostOffice)sc.getAttribute(postOfficeObjectName, "Instance");
+
+ return postOffice.getRecoveryArea(queueName);
}
-
+
public int getRecoveryMapSize(String queueName) throws Exception
{
- PostOffice postOffice = (PostOffice)sc.getAttribute(postOfficeObjectName, "Instance");
-
- return postOffice.getRecoveryMapSize(queueName);
+ PostOffice postOffice = (PostOffice)sc.getAttribute(postOfficeObjectName, "Instance");
+
+ return postOffice.getRecoveryMapSize(queueName);
}
public List pollNotificationListener(long listenerID) throws Exception
{
- throw new IllegalStateException("Poll doesn't make sense on a local server. " +
- "Register listeners directly instead.");
+ throw new IllegalStateException("Poll doesn't make sense on a local server. " + "Register listeners directly instead.");
}
public void poisonTheServer(int type) throws Exception
{
URL url = this.getClass().getClassLoader().getResource("poison.xml");
- if(url == null) // JBMESSAGING-1222 - Hack for OSX JVM Bug when testing the remote connectors
- { //(Assumes tests are being executed is the jboss-messaging/tests directory)
-
- url = (new File("etc/poison.xml")).toURL();
+ if (url == null) // JBMESSAGING-1222 - Hack for OSX JVM Bug when testing the remote connectors
+ { // (Assumes tests are being executed is the jboss-messaging/tests directory)
+
+ url = (new File("etc/poison.xml")).toURL();
}
AspectXmlLoader.deployXML(url);
log.debug(url + " deployed");
PoisonInterceptor.setType(type);
- }
-
+ }
+
public void flushManagedConnectionPool()
{
- sc.flushManagedConnectionPool();
+ sc.flushManagedConnectionPool();
}
-
+
public void resetAllSuckers() throws Exception
{
- getServerPeer().resetAllSuckers();
+ getServerPeer().resetAllSuckers();
}
-
+
// Public ---------------------------------------------------------------------------------------
// Package protected ----------------------------------------------------------------------------
@@ -941,20 +1075,20 @@
}
protected void overrideServerPeerConfiguration(MBeanConfigurationElement config,
- int serverPeerID, String defaultQueueJNDIContext, String defaultTopicJNDIContext)
- throws Exception
+ int serverPeerID,
+ String defaultQueueJNDIContext,
+ String defaultTopicJNDIContext) throws Exception
{
config.setAttribute("ServerPeerID", Integer.toString(serverPeerID));
- config.setAttribute("DefaultQueueJNDIContext",
- defaultQueueJNDIContext == null ? "/queue" : defaultQueueJNDIContext);
- config.setAttribute("DefaultTopicJNDIContext",
- defaultTopicJNDIContext == null? "/topic" : defaultTopicJNDIContext);
+ config.setAttribute("DefaultQueueJNDIContext", defaultQueueJNDIContext == null ? "/queue"
+ : defaultQueueJNDIContext);
+ config.setAttribute("DefaultTopicJNDIContext", defaultTopicJNDIContext == null ? "/topic"
+ : defaultTopicJNDIContext);
}
// Private --------------------------------------------------------------------------------------
- private void overrideAttributes(ObjectName on, ServiceAttributeOverrides attrOverrides)
- throws Exception
+ private void overrideAttributes(ObjectName on, ServiceAttributeOverrides attrOverrides) throws Exception
{
if (attrOverrides == null)
{
@@ -963,7 +1097,7 @@
Map sao = attrOverrides.get(on);
- for(Iterator i = sao.entrySet().iterator(); i.hasNext();)
+ for (Iterator i = sao.entrySet().iterator(); i.hasNext();)
{
Map.Entry entry = (Map.Entry)i.next();
String attrName = (String)entry.getKey();
Modified: branches/Branch_1_4/integration/EAP4/tests-src/org/jboss/test/messaging/tools/container/LocalTestServer.java
===================================================================
--- branches/Branch_1_4/integration/EAP4/tests-src/org/jboss/test/messaging/tools/container/LocalTestServer.java 2008-09-24 23:08:48 UTC (rev 5023)
+++ branches/Branch_1_4/integration/EAP4/tests-src/org/jboss/test/messaging/tools/container/LocalTestServer.java 2008-09-25 04:52:34 UTC (rev 5024)
@@ -1,24 +1,14 @@
/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
+ * JBoss, Home of Professional Open Source Copyright 2005, JBoss Inc., and individual contributors as indicated by the
+ * @authors tag. See the copyright.txt in the distribution for a full listing of individual contributors. This is free
+ * software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+ * This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details. You should have received a copy of the GNU Lesser General Public License along with this software; if not,
+ * write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
+ */
package org.jboss.test.messaging.tools.container;
import java.net.URL;
@@ -53,9 +43,7 @@
/**
* @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>1.1</tt>
- *
- * LocalTestServer.java,v 1.1 2006/02/21 08:25:32 timfox Exp
+ * @version <tt>1.1</tt> LocalTestServer.java,v 1.1 2006/02/21 08:25:32 timfox Exp
*/
public class LocalTestServer implements Server
{
@@ -79,9 +67,11 @@
private ServiceContainer sc;
- // service dependencies
+ // service dependencies
private ObjectName persistenceManagerObjectName;
+
private ObjectName postOfficeObjectName;
+
private ObjectName jmsUserManagerObjectName;
// the server MBean itself
@@ -110,8 +100,7 @@
return serverIndex;
}
- public void start(String containerConfig,
- boolean clearDatabase) throws Exception
+ public void start(String containerConfig, boolean clearDatabase) throws Exception
{
start(containerConfig, null, clearDatabase, true);
}
@@ -186,7 +175,6 @@
return true;
}
-
public void ping() throws Exception
{
// noop... do nothing
@@ -219,20 +207,17 @@
sc.setAttribute(on, name, valueAsString);
}
- public Object invoke(ObjectName on, String operationName, Object[] params, String[] signature)
- throws Exception
+ public Object invoke(ObjectName on, String operationName, Object[] params, String[] signature) throws Exception
{
return sc.invoke(on, operationName, params, signature);
}
- public void addNotificationListener(ObjectName on, NotificationListener listener)
- throws Exception
+ public void addNotificationListener(ObjectName on, NotificationListener listener) throws Exception
{
sc.addNotificationListener(on, listener);
}
- public void removeNotificationListener(ObjectName on, NotificationListener listener)
- throws Exception
+ public void removeNotificationListener(ObjectName on, NotificationListener listener) throws Exception
{
sc.removeNotificationListener(on, listener);
}
@@ -291,7 +276,7 @@
ServiceAttributeOverrides attrOverrides,
boolean clustered) throws Exception
{
- List toStop = new ArrayList();
+ List toStop = new ArrayList();
try
{
log.debug("creating ServerPeer instance");
@@ -300,65 +285,63 @@
// src/etc/server/default/deploy. This will allow to test the default parameters we ship.
String mainConfigFile = "server/default/deploy/messaging-service.xml";
-
+
String persistenceConfigFile = sc.getPersistenceConfigFile(clustered);
log.info(" Persistence config file .. " + persistenceConfigFile);
ServiceDeploymentDescriptor mdd = ServiceConfigHelper.loadConfigFile(mainConfigFile);
-
+
ServiceDeploymentDescriptor pdd = ServiceConfigHelper.loadConfigFile(persistenceConfigFile);
- MBeanConfigurationElement persistenceManagerConfig =
- ServiceConfigHelper.getServiceConfiguration(pdd, "PersistenceManager");
+ MBeanConfigurationElement persistenceManagerConfig = ServiceConfigHelper.getServiceConfiguration(pdd,
+ "PersistenceManager");
persistenceManagerObjectName = sc.registerAndConfigureService(persistenceManagerConfig);
overrideAttributes(persistenceManagerObjectName, attrOverrides);
toStop.add(persistenceManagerObjectName);
sc.invoke(persistenceManagerObjectName, "create", new Object[0], new String[0]);
- sc.invoke(persistenceManagerObjectName, "start", new Object[0], new String[0]);
+ sc.invoke(persistenceManagerObjectName, "start", new Object[0], new String[0]);
- MBeanConfigurationElement jmsUserManagerConfig =
- ServiceConfigHelper.getServiceConfiguration(pdd, "JMSUserManager");
+ MBeanConfigurationElement jmsUserManagerConfig = ServiceConfigHelper.getServiceConfiguration(pdd,
+ "JMSUserManager");
jmsUserManagerObjectName = sc.registerAndConfigureService(jmsUserManagerConfig);
- overrideAttributes(jmsUserManagerObjectName, attrOverrides);
+ overrideAttributes(jmsUserManagerObjectName, attrOverrides);
toStop.add(jmsUserManagerObjectName);
sc.invoke(jmsUserManagerObjectName, "create", new Object[0], new String[0]);
sc.invoke(jmsUserManagerObjectName, "start", new Object[0], new String[0]);
// register server peer as a service, dependencies are injected automatically
- MBeanConfigurationElement serverPeerConfig =
- ServiceConfigHelper.getServiceConfiguration(mdd, "ServerPeer");
+ MBeanConfigurationElement serverPeerConfig = ServiceConfigHelper.getServiceConfiguration(mdd, "ServerPeer");
// overwrite the file configuration, if needed
- overrideServerPeerConfiguration(serverPeerConfig, serverPeerID, defaultQueueJNDIContext,
- defaultTopicJNDIContext);
+ overrideServerPeerConfiguration(serverPeerConfig,
+ serverPeerID,
+ defaultQueueJNDIContext,
+ defaultTopicJNDIContext);
serverPeerObjectName = sc.registerAndConfigureService(serverPeerConfig);
overrideAttributes(serverPeerObjectName, attrOverrides);
// overwrite the config file security domain
- sc.setAttribute(serverPeerObjectName, "SecurityDomain",
- MockJBossSecurityManager.TEST_SECURITY_DOMAIN);
+ sc.setAttribute(serverPeerObjectName, "SecurityDomain", MockJBossSecurityManager.TEST_SECURITY_DOMAIN);
log.debug("starting JMS server");
toStop.add(serverPeerObjectName);
sc.invoke(serverPeerObjectName, "create", new Object[0], new String[0]);
sc.invoke(serverPeerObjectName, "start", new Object[0], new String[0]);
-
- MBeanConfigurationElement postOfficeConfig =
- ServiceConfigHelper.getServiceConfiguration(pdd, "PostOffice");
+ MBeanConfigurationElement postOfficeConfig = ServiceConfigHelper.getServiceConfiguration(pdd, "PostOffice");
- postOfficeObjectName = sc.registerAndConfigureService(postOfficeConfig);
- sc.setAttribute(postOfficeObjectName, "Clustered", clustered ? "true" : "false");
-
+ postOfficeObjectName = sc.registerAndConfigureService(postOfficeConfig);
+ sc.setAttribute(postOfficeObjectName, "Clustered", clustered ? "true" : "false");
+
overrideAttributes(postOfficeObjectName, attrOverrides);
toStop.add(postOfficeObjectName);
sc.invoke(postOfficeObjectName, "create", new Object[0], new String[0]);
- sc.invoke(postOfficeObjectName, "start", new Object[0], new String[0]);
+ sc.invoke(postOfficeObjectName, "start", new Object[0], new String[0]);
log.debug("deploying connection factories");
sc.startConnectionFactories(attrOverrides);
@@ -366,21 +349,21 @@
catch (Exception e)
{
log.error("Failed to start", e);
-
- //Now we need to shutdown any services we did start
+
+ // Now we need to shutdown any services we did start
for (int i = toStop.size() - 1; i >= 0; i--)
{
- ObjectName on = (ObjectName)toStop.get(i);
- log.info("stopping: " + on);
- try
- {
- sc.unregisterService(on);
- }
- catch (Exception ignore)
- {
- }
+ ObjectName on = (ObjectName)toStop.get(i);
+ log.info("stopping: " + on);
+ try
+ {
+ sc.unregisterService(on);
+ }
+ catch (Exception ignore)
+ {
+ }
}
-
+
throw e;
}
}
@@ -415,36 +398,36 @@
try
{
- Set destinations = (Set)sc.getAttribute(serverPeerObjectName, "Destinations");
-
- for(Iterator i = destinations.iterator(); i.hasNext(); )
- {
- String name;
- boolean isQueue = true;
- Destination d = (Destination)i.next();
- if (d instanceof Queue)
- {
- name = ((Queue)d).getQueueName();
- }
- else
- {
- isQueue = false;
- name = ((Topic)d).getTopicName();
- }
-
- try
- {
- undeployDestination(isQueue, name);
- }
- catch (Exception e)
- {
- //needs to be resilient
- }
- }
+ Set destinations = (Set)sc.getAttribute(serverPeerObjectName, "Destinations");
+
+ for (Iterator i = destinations.iterator(); i.hasNext();)
+ {
+ String name;
+ boolean isQueue = true;
+ Destination d = (Destination)i.next();
+ if (d instanceof Queue)
+ {
+ name = ((Queue)d).getQueueName();
+ }
+ else
+ {
+ isQueue = false;
+ name = ((Topic)d).getTopicName();
+ }
+
+ try
+ {
+ undeployDestination(isQueue, name);
+ }
+ catch (Exception e)
+ {
+ // needs to be resilient
+ }
+ }
}
catch (Exception ignore)
{
- //Needs to be resilient on close
+ // Needs to be resilient on close
}
log.debug("stopping JMS server");
@@ -457,10 +440,10 @@
}
catch (Exception ignore)
{
- //If the serverpeer failed when starting up previously, then only some of the
- //services may be started. The ones that didn't start will fail when attempting to shut
- //them down.
- //Hence we must catch and ignore or we won't shut everything down
+ // If the serverpeer failed when starting up previously, then only some of the
+ // services may be started. The ones that didn't start will fail when attempting to shut
+ // them down.
+ // Hence we must catch and ignore or we won't shut everything down
}
log.debug("stopping ServerPeer's plug-in dependencies");
@@ -473,10 +456,10 @@
}
catch (Exception ignore)
{
- //If the serverpeer failed when starting up previously, then only some of the
- //services may be started. The ones that didn't start will fail when attempting to shut
- //them down.
- //Hence we must catch and ignore or we won't shut everything down
+ // If the serverpeer failed when starting up previously, then only some of the
+ // services may be started. The ones that didn't start will fail when attempting to shut
+ // them down.
+ // Hence we must catch and ignore or we won't shut everything down
}
try
@@ -487,10 +470,10 @@
}
catch (Exception ignore)
{
- //If the serverpeer failed when starting up previously, then only some of the
- //services may be started. The ones that didn't start will fail when attempting to shut
- //them down.
- //Hence we must catch and ignore or we won't shut everything down
+ // If the serverpeer failed when starting up previously, then only some of the
+ // services may be started. The ones that didn't start will fail when attempting to shut
+ // them down.
+ // Hence we must catch and ignore or we won't shut everything down
}
try
@@ -501,10 +484,10 @@
}
catch (Exception ignore)
{
- //If the serverpeer failed when starting up previously, then only some of the
- //services may be started. The ones that didn't start will fail when attempting to shut
- //them down.
- //Hence we must catch and ignore or we won't shut everything down
+ // If the serverpeer failed when starting up previously, then only some of the
+ // services may be started. The ones that didn't start will fail when attempting to shut
+ // them down.
+ // Hence we must catch and ignore or we won't shut everything down
}
}
catch (Exception e)
@@ -532,25 +515,21 @@
public Set getConnectorSubsystems() throws Exception
{
- RemotingJMXWrapper remoting =
- (RemotingJMXWrapper)sc.getService(ServiceContainer.REMOTING_OBJECT_NAME);
+ RemotingJMXWrapper remoting = (RemotingJMXWrapper)sc.getService(ServiceContainer.REMOTING_OBJECT_NAME);
return remoting.getConnectorSubsystems();
}
- public void addServerInvocationHandler(String subsystem, ServerInvocationHandler handler)
- throws Exception
+ public void addServerInvocationHandler(String subsystem, ServerInvocationHandler handler) throws Exception
{
- RemotingJMXWrapper remoting =
- (RemotingJMXWrapper)sc.getService(ServiceContainer.REMOTING_OBJECT_NAME);
+ RemotingJMXWrapper remoting = (RemotingJMXWrapper)sc.getService(ServiceContainer.REMOTING_OBJECT_NAME);
remoting.addInvocationHandler(subsystem, handler);
}
public void removeServerInvocationHandler(String subsystem) throws Exception
{
- RemotingJMXWrapper remoting =
- (RemotingJMXWrapper)sc.getService(ServiceContainer.REMOTING_OBJECT_NAME);
+ RemotingJMXWrapper remoting = (RemotingJMXWrapper)sc.getService(ServiceContainer.REMOTING_OBJECT_NAME);
remoting.removeInvocationHandler(subsystem);
}
@@ -581,8 +560,7 @@
*/
public ServerPeer getServerPeer() throws Exception
{
- return (ServerPeer)sc.
- getAttribute(serverPeerObjectName, "Instance");
+ return (ServerPeer)sc.getAttribute(serverPeerObjectName, "Instance");
}
public void deployTopic(String name, String jndiName, boolean clustered) throws Exception
@@ -590,17 +568,22 @@
deployDestination(false, name, jndiName, clustered);
}
- public void deployTopic(String name, String jndiName, int fullSize, int pageSize,
- int downCacheSize, boolean clustered) throws Exception
+ public void deployTopic(String name,
+ String jndiName,
+ int fullSize,
+ int pageSize,
+ int downCacheSize,
+ boolean clustered) throws Exception
{
deployDestination(false, name, jndiName, fullSize, pageSize, downCacheSize, clustered);
}
public void deployTopicProgrammatically(String name, String jndiName) throws Exception
{
- sc.invoke(serverPeerObjectName, "deployTopic",
+ sc.invoke(serverPeerObjectName,
+ "deployTopic",
new Object[] { name, jndiName },
- new String[] { "java.lang.String", "java.lang.String"} );
+ new String[] { "java.lang.String", "java.lang.String" });
}
public void deployQueue(String name, String jndiName, boolean clustered) throws Exception
@@ -608,32 +591,142 @@
deployDestination(true, name, jndiName, clustered);
}
- public void deployQueue(String name, String jndiName, int fullSize, int pageSize,
- int downCacheSize, boolean clustered) throws Exception
+ public void deployQueue(String name,
+ String jndiName,
+ int fullSize,
+ int pageSize,
+ int downCacheSize,
+ boolean clustered) throws Exception
{
deployDestination(true, name, jndiName, fullSize, pageSize, downCacheSize, clustered);
}
public void deployQueueProgrammatically(String name, String jndiName) throws Exception
{
- sc.invoke(serverPeerObjectName, "deployQueue",
+ sc.invoke(serverPeerObjectName,
+ "deployQueue",
new Object[] { name, jndiName },
- new String[] { "java.lang.String", "java.lang.String"} );
+ new String[] { "java.lang.String", "java.lang.String" });
}
+ public ObjectName deployQueueWithDLQnExpiryQ(String q, String dlq, String expq) throws Exception
+ {
+ String config = "<mbean code=\"org.jboss.jms.server.destination." + "QueueService" +
+ "\"" +
+ " name=\"jboss.messaging.destination:service=" +
+ "Queue" +
+ ",name=" +
+ q +
+ "\"" +
+ " xmbean-dd=\"xmdesc/" +
+ "Queue" +
+ "-xmbean.xml\">" +
+ " <depends optional-attribute-name=\"ServerPeer\">jboss.messaging:service=ServerPeer</depends>" +
+ " <depends>jboss.messaging:service=PostOffice</depends>" +
+ " <attribute name=\"DLQ\">" +
+ "jboss.messaging.destination:service=Queue,name=" +
+ dlq +
+ "</attribute>" +
+ " <attribute name=\"ExpiryQueue\">" +
+ "jboss.messaging.destination:service=Queue,name=" +
+ expq +
+ "</attribute>" +
+ "</mbean>";
+
+ MBeanConfigurationElement mbean = new MBeanConfigurationElement(XMLUtil.stringToElement(config));
+ ObjectName deston = sc.registerAndConfigureService(mbean);
+ sc.invoke(deston, "create", new Object[0], new String[0]);
+ // sc.invoke(deston, "start", new Object[0], new String[0]);
+ return deston;
+ }
+
+ public ObjectName deployTopicWithDLQnExpiryQ(String topic, String dlq, String expq) throws Exception
+ {
+ String config = "<mbean code=\"org.jboss.jms.server.destination." + "TopicService" +
+ "\"" +
+ " name=\"jboss.messaging.destination:service=" +
+ "Topic" +
+ ",name=" +
+ topic +
+ "\"" +
+ " xmbean-dd=\"xmdesc/" +
+ "Topic" +
+ "-xmbean.xml\">" +
+ " <depends optional-attribute-name=\"ServerPeer\">jboss.messaging:service=ServerPeer</depends>" +
+ " <depends>jboss.messaging:service=PostOffice</depends>" +
+ " <attribute name=\"DLQ\">" +
+ "jboss.messaging.destination:service=Queue,name=" +
+ dlq +
+ "</attribute>" +
+ " <attribute name=\"ExpiryQueue\">" +
+ "jboss.messaging.destination:service=Queue,name=" +
+ expq +
+ "</attribute>" +
+ "</mbean>";
+
+ MBeanConfigurationElement mbean = new MBeanConfigurationElement(XMLUtil.stringToElement(config));
+ ObjectName deston = sc.registerAndConfigureService(mbean);
+ sc.invoke(deston, "create", new Object[0], new String[0]);
+ return deston;
+ }
+
+ public ObjectName deployQueueWithoutStart(String q, String jndiName, boolean b) throws Exception
+ {
+ String config = "<mbean code=\"org.jboss.jms.server.destination." + "QueueService" +
+ "\"" +
+ " name=\"jboss.messaging.destination:service=" +
+ "Queue" +
+ ",name=" +
+ q +
+ "\"" +
+ " xmbean-dd=\"xmdesc/" +
+ "Queue" +
+ "-xmbean.xml\">" +
+ (jndiName != null ? " <attribute name=\"JNDIName\">" + jndiName + "</attribute>" : "") +
+ " <depends optional-attribute-name=\"ServerPeer\">jboss.messaging:service=ServerPeer</depends>" +
+ " <depends>jboss.messaging:service=PostOffice</depends>" +
+ " <attribute name=\"Clustered\">" +
+ String.valueOf(b) +
+ "</attribute>" +
+ "</mbean>";
+
+ MBeanConfigurationElement mbean = new MBeanConfigurationElement(XMLUtil.stringToElement(config));
+ ObjectName deston = sc.registerAndConfigureService(mbean);
+ sc.invoke(deston, "create", new Object[0], new String[0]);
+ return deston;
+ }
+
+ /**
+ * start the services.
+ */
+ public void startDestinationService(ObjectName[] objectNames) throws Exception
+ {
+ for (ObjectName sv : objectNames)
+ {
+ sc.invoke(sv, "start", new Object[0], new String[0]);
+ }
+ }
+
public void deployDestination(boolean isQueue, String name, String jndiName, boolean clustered) throws Exception
{
- String config =
- "<mbean code=\"org.jboss.jms.server.destination." + (isQueue ? "QueueService" : "TopicService") + "\"" +
- " name=\"jboss.messaging.destination:service=" + (isQueue ? "Queue" : "Topic") + ",name=" + name + "\"" +
- " xmbean-dd=\"xmdesc/" + (isQueue ? "Queue" : "Topic" ) + "-xmbean.xml\">" +
- (jndiName != null ? " <attribute name=\"JNDIName\">" + jndiName + "</attribute>" : "") +
- " <depends optional-attribute-name=\"ServerPeer\">jboss.messaging:service=ServerPeer</depends>" +
- " <attribute name=\"Clustered\">" + String.valueOf(clustered) + "</attribute>" +
- "</mbean>";
+ String config = "<mbean code=\"org.jboss.jms.server.destination." + (isQueue ? "QueueService" : "TopicService") +
+ "\"" +
+ " name=\"jboss.messaging.destination:service=" +
+ (isQueue ? "Queue" : "Topic") +
+ ",name=" +
+ name +
+ "\"" +
+ " xmbean-dd=\"xmdesc/" +
+ (isQueue ? "Queue" : "Topic") +
+ "-xmbean.xml\">" +
+ (jndiName != null ? " <attribute name=\"JNDIName\">" + jndiName + "</attribute>" : "") +
+ " <depends optional-attribute-name=\"ServerPeer\">jboss.messaging:service=ServerPeer</depends>" +
+ " <attribute name=\"Clustered\">" +
+ String.valueOf(clustered) +
+ "</attribute>" +
+ "</mbean>";
- MBeanConfigurationElement mbean =
- new MBeanConfigurationElement(XMLUtil.stringToElement(config));
+ MBeanConfigurationElement mbean = new MBeanConfigurationElement(XMLUtil.stringToElement(config));
ObjectName deston = sc.registerAndConfigureService(mbean);
sc.invoke(deston, "create", new Object[0], new String[0]);
sc.invoke(deston, "start", new Object[0], new String[0]);
@@ -649,20 +742,33 @@
{
log.info("deploying queue, fullsize:" + fullSize + ", ps:" + pageSize + " dc size:" + downCacheSize);
- String config =
- "<mbean code=\"org.jboss.jms.server.destination." + (isQueue ? "QueueService" : "TopicService") + "\"" +
- " name=\"jboss.messaging.destination:service=" + (isQueue ? "Queue" : "Topic") + ",name=" + name + "\"" +
- " xmbean-dd=\"xmdesc/" + (isQueue ? "Queue" : "Topic" ) + "-xmbean.xml\">" +
- (jndiName != null ? " <attribute name=\"JNDIName\">" + jndiName + "</attribute>" : "") +
- " <depends optional-attribute-name=\"ServerPeer\">jboss.messaging:service=ServerPeer</depends>" +
- " <attribute name=\"FullSize\">" + fullSize + "</attribute>" +
- " <attribute name=\"PageSize\">" + pageSize + "</attribute>" +
- " <attribute name=\"DownCacheSize\">" + downCacheSize + "</attribute>" +
- " <attribute name=\"Clustered\">" + String.valueOf(clustered) + "</attribute>" +
- "</mbean>";
+ String config = "<mbean code=\"org.jboss.jms.server.destination." + (isQueue ? "QueueService" : "TopicService") +
+ "\"" +
+ " name=\"jboss.messaging.destination:service=" +
+ (isQueue ? "Queue" : "Topic") +
+ ",name=" +
+ name +
+ "\"" +
+ " xmbean-dd=\"xmdesc/" +
+ (isQueue ? "Queue" : "Topic") +
+ "-xmbean.xml\">" +
+ (jndiName != null ? " <attribute name=\"JNDIName\">" + jndiName + "</attribute>" : "") +
+ " <depends optional-attribute-name=\"ServerPeer\">jboss.messaging:service=ServerPeer</depends>" +
+ " <attribute name=\"FullSize\">" +
+ fullSize +
+ "</attribute>" +
+ " <attribute name=\"PageSize\">" +
+ pageSize +
+ "</attribute>" +
+ " <attribute name=\"DownCacheSize\">" +
+ downCacheSize +
+ "</attribute>" +
+ " <attribute name=\"Clustered\">" +
+ String.valueOf(clustered) +
+ "</attribute>" +
+ "</mbean>";
- MBeanConfigurationElement mbean =
- new MBeanConfigurationElement(XMLUtil.stringToElement(config));
+ MBeanConfigurationElement mbean = new MBeanConfigurationElement(XMLUtil.stringToElement(config));
ObjectName deston = sc.registerAndConfigureService(mbean);
sc.invoke(deston, "create", new Object[0], new String[0]);
sc.invoke(deston, "start", new Object[0], new String[0]);
@@ -670,8 +776,7 @@
public void undeployDestination(boolean isQueue, String name) throws Exception
{
- ObjectName pattern =
- new ObjectName("*:service=" + (isQueue ? "Queue" : "Topic") + ",name=" + name);
+ ObjectName pattern = new ObjectName("*:service=" + (isQueue ? "Queue" : "Topic") + ",name=" + name);
Set s = sc.query(pattern);
int size = s.size();
if (size == 0)
@@ -693,90 +798,116 @@
{
if (isQueue)
{
- return ((Boolean)sc.invoke(serverPeerObjectName, "undeployQueue",
+ return ((Boolean)sc.invoke(serverPeerObjectName,
+ "undeployQueue",
new Object[] { name },
- new String[] { "java.lang.String"})).booleanValue();
+ new String[] { "java.lang.String" })).booleanValue();
}
else
{
- return ((Boolean)sc.invoke(serverPeerObjectName, "undeployTopic",
+ return ((Boolean)sc.invoke(serverPeerObjectName,
+ "undeployTopic",
new Object[] { name },
- new String[] { "java.lang.String"})).booleanValue();
+ new String[] { "java.lang.String" })).booleanValue();
}
}
- public void deployConnectionFactory(String objectName,
- String[] jndiBindings,
- int prefetchSize) throws Exception
+ public void deployConnectionFactory(String objectName, String[] jndiBindings, int prefetchSize) throws Exception
{
deployConnectionFactory(objectName, jndiBindings, prefetchSize, -1, -1, -1, false, false, false, null);
}
- public void deployConnectionFactory(String objectName,
- String[] jndiBindings) throws Exception
+ public void deployConnectionFactory(String objectName, String[] jndiBindings) throws Exception
{
deployConnectionFactory(objectName, jndiBindings, -1, -1, -1, -1, false, false, false, null);
}
-
- public void deployConnectionFactory(String objectName, String[] jndiBindings, boolean strictTck) throws Exception
- {
- deployConnectionFactory(objectName, jndiBindings, -1, -1, -1, -1, false, false, strictTck, null);
- }
-
- public void deployConnectionFactory(String objectName,
- String[] jndiBindings,
- int prefetchSize,
- int defaultTempQueueFullSize,
- int defaultTempQueuePageSize,
- int defaultTempQueueDownCacheSize) throws Exception
+ public void deployConnectionFactory(String objectName, String[] jndiBindings, boolean strictTck) throws Exception
{
- this.deployConnectionFactory(objectName, jndiBindings, prefetchSize, defaultTempQueueFullSize,
- defaultTempQueuePageSize, defaultTempQueueDownCacheSize, false, false, false, null);
+ deployConnectionFactory(objectName, jndiBindings, -1, -1, -1, -1, false, false, strictTck, null);
}
-
+
public void deployConnectionFactory(String objectName,
- String[] jndiBindings,
- boolean supportsFailover, boolean supportsLoadBalancing) throws Exception
+ String[] jndiBindings,
+ int prefetchSize,
+ int defaultTempQueueFullSize,
+ int defaultTempQueuePageSize,
+ int defaultTempQueueDownCacheSize) throws Exception
{
- this.deployConnectionFactory(objectName, jndiBindings, -1, -1,
- -1, -1, supportsFailover, supportsLoadBalancing, false, null);
+ this.deployConnectionFactory(objectName,
+ jndiBindings,
+ prefetchSize,
+ defaultTempQueueFullSize,
+ defaultTempQueuePageSize,
+ defaultTempQueueDownCacheSize,
+ false,
+ false,
+ false,
+ null);
}
-
+
public void deployConnectionFactory(String objectName,
- String[] jndiBindings,
- boolean supportsFailover, boolean supportsLoadBalancing, String clientID) throws Exception
+ String[] jndiBindings,
+ boolean supportsFailover,
+ boolean supportsLoadBalancing) throws Exception
{
- this.deployConnectionFactory(objectName, jndiBindings, -1, -1,
- -1, -1, supportsFailover, supportsLoadBalancing, false, clientID);
+ this.deployConnectionFactory(objectName,
+ jndiBindings,
+ -1,
+ -1,
+ -1,
+ -1,
+ supportsFailover,
+ supportsLoadBalancing,
+ false,
+ null);
}
- private void deployConnectionFactory(String objectName,
+ public void deployConnectionFactory(String objectName,
String[] jndiBindings,
- int prefetchSize,
- int defaultTempQueueFullSize,
- int defaultTempQueuePageSize,
- int defaultTempQueueDownCacheSize,
boolean supportsFailover,
boolean supportsLoadBalancing,
- boolean strictTck,
String clientID) throws Exception
{
+ this.deployConnectionFactory(objectName,
+ jndiBindings,
+ -1,
+ -1,
+ -1,
+ -1,
+ supportsFailover,
+ supportsLoadBalancing,
+ false,
+ clientID);
+ }
+
+ private void deployConnectionFactory(String objectName,
+ String[] jndiBindings,
+ int prefetchSize,
+ int defaultTempQueueFullSize,
+ int defaultTempQueuePageSize,
+ int defaultTempQueueDownCacheSize,
+ boolean supportsFailover,
+ boolean supportsLoadBalancing,
+ boolean strictTck,
+ String clientID) throws Exception
+ {
log.trace("deploying connection factory with name: " + objectName);
-
- String config =
- "<mbean code=\"org.jboss.jms.server.connectionfactory.ConnectionFactory\"\n" +
- "name=\"" + objectName + "\"\n" +
- "xmbean-dd=\"xmdesc/ConnectionFactory-xmbean.xml\">\n" +
- "<depends optional-attribute-name=\"ServerPeer\">jboss.messaging:service=ServerPeer</depends>\n" +
- "<depends optional-attribute-name=\"Connector\">" + ServiceContainer.REMOTING_OBJECT_NAME +
- "</depends>\n";
-//<arg type="java.lang.String" value="MyClientID"/>
+
+ String config = "<mbean code=\"org.jboss.jms.server.connectionfactory.ConnectionFactory\"\n" + "name=\"" +
+ objectName +
+ "\"\n" +
+ "xmbean-dd=\"xmdesc/ConnectionFactory-xmbean.xml\">\n" +
+ "<depends optional-attribute-name=\"ServerPeer\">jboss.messaging:service=ServerPeer</depends>\n" +
+ "<depends optional-attribute-name=\"Connector\">" +
+ ServiceContainer.REMOTING_OBJECT_NAME +
+ "</depends>\n";
+ // <arg type="java.lang.String" value="MyClientID"/>
if (clientID != null)
{
config += "<constructor><arg type=\"java.lang.String\" value=\"" + clientID + "\"/> </constructor>\n";
}
-
+
if (defaultTempQueueFullSize != -1)
{
config += "<attribute name=\"DefaultTempQueueFullSize\">" + defaultTempQueueFullSize + "</attribute>\n";
@@ -789,35 +920,35 @@
if (defaultTempQueueDownCacheSize != -1)
{
- config += "<attribute name=\"DefaultTempQueueDownCacheSize\">" + defaultTempQueueDownCacheSize + "</attribute>\n";
+ config += "<attribute name=\"DefaultTempQueueDownCacheSize\">" + defaultTempQueueDownCacheSize +
+ "</attribute>\n";
}
if (prefetchSize != -1)
{
config += "<attribute name=\"PrefetchSize\">" + prefetchSize + "</attribute>";
}
-
+
config += "<attribute name=\"SupportsFailover\">" + supportsFailover + "</attribute>";
config += "<attribute name=\"SupportsLoadBalancing\">" + supportsLoadBalancing + "</attribute>";
config += "<attribute name=\"StrictTck\">" + strictTck + "</attribute>";
if (jndiBindings != null)
{
- config += "<attribute name=\"JNDIBindings\"><bindings>";
-
- for (int i = 0; i < jndiBindings.length; i++)
- {
- config += "<binding>" + jndiBindings[i] + "</binding>\n";
- }
- config += "</bindings></attribute>";
+ config += "<attribute name=\"JNDIBindings\"><bindings>";
+
+ for (int i = 0; i < jndiBindings.length; i++)
+ {
+ config += "<binding>" + jndiBindings[i] + "</binding>\n";
+ }
+ config += "</bindings></attribute>";
}
config += "</mbean>";
MBeanConfigurationElement mc = new MBeanConfigurationElement(XMLUtil.stringToElement(config));
ObjectName on = sc.registerAndConfigureService(mc);
-
-
+
log.trace("Object name is now: " + on);
-
+
sc.invoke(on, "create", new Object[0], new String[0]);
sc.invoke(on, "start", new Object[0], new String[0]);
}
@@ -832,14 +963,14 @@
public void configureSecurityForDestination(String destName, String config) throws Exception
{
Set s = sc.query(new ObjectName("*:service=Queue,name=" + destName));
- for(Iterator i = s.iterator(); i.hasNext();)
+ for (Iterator i = s.iterator(); i.hasNext();)
{
ObjectName on = (ObjectName)i.next();
sc.setAttribute(on, "SecurityConfig", config);
}
s = sc.query(new ObjectName("*:service=Topic,name=" + destName));
- for(Iterator i = s.iterator(); i.hasNext();)
+ for (Iterator i = s.iterator(); i.hasNext();)
{
ObjectName on = (ObjectName)i.next();
sc.setAttribute(on, "SecurityConfig", config);
@@ -869,36 +1000,35 @@
public Set getNodeIDView() throws Exception
{
- PostOffice postOffice = (PostOffice)sc.getAttribute(postOfficeObjectName, "Instance");
-
- return postOffice.nodeIDView();
+ PostOffice postOffice = (PostOffice)sc.getAttribute(postOfficeObjectName, "Instance");
+
+ return postOffice.nodeIDView();
}
-
+
public Map getFailoverMap() throws Exception
{
- PostOffice postOffice = (PostOffice)sc.getAttribute(postOfficeObjectName, "Instance");
-
- return postOffice.getFailoverMap();
+ PostOffice postOffice = (PostOffice)sc.getAttribute(postOfficeObjectName, "Instance");
+
+ return postOffice.getFailoverMap();
}
-
+
public Map getRecoveryArea(String queueName) throws Exception
{
- PostOffice postOffice = (PostOffice)sc.getAttribute(postOfficeObjectName, "Instance");
-
- return postOffice.getRecoveryArea(queueName);
+ PostOffice postOffice = (PostOffice)sc.getAttribute(postOfficeObjectName, "Instance");
+
+ return postOffice.getRecoveryArea(queueName);
}
-
+
public int getRecoveryMapSize(String queueName) throws Exception
{
- PostOffice postOffice = (PostOffice)sc.getAttribute(postOfficeObjectName, "Instance");
-
- return postOffice.getRecoveryMapSize(queueName);
+ PostOffice postOffice = (PostOffice)sc.getAttribute(postOfficeObjectName, "Instance");
+
+ return postOffice.getRecoveryMapSize(queueName);
}
public List pollNotificationListener(long listenerID) throws Exception
{
- throw new IllegalStateException("Poll doesn't make sense on a local server. " +
- "Register listeners directly instead.");
+ throw new IllegalStateException("Poll doesn't make sense on a local server. " + "Register listeners directly instead.");
}
public void poisonTheServer(int type) throws Exception
@@ -909,18 +1039,18 @@
log.debug(url + " deployed");
PoisonInterceptor.setType(type);
- }
-
+ }
+
public void flushManagedConnectionPool()
{
- sc.flushManagedConnectionPool();
+ sc.flushManagedConnectionPool();
}
-
+
public void resetAllSuckers() throws Exception
{
- getServerPeer().resetAllSuckers();
+ getServerPeer().resetAllSuckers();
}
-
+
// Public ---------------------------------------------------------------------------------------
// Package protected ----------------------------------------------------------------------------
@@ -933,20 +1063,20 @@
}
protected void overrideServerPeerConfiguration(MBeanConfigurationElement config,
- int serverPeerID, String defaultQueueJNDIContext, String defaultTopicJNDIContext)
- throws Exception
+ int serverPeerID,
+ String defaultQueueJNDIContext,
+ String defaultTopicJNDIContext) throws Exception
{
config.setAttribute("ServerPeerID", Integer.toString(serverPeerID));
- config.setAttribute("DefaultQueueJNDIContext",
- defaultQueueJNDIContext == null ? "/queue" : defaultQueueJNDIContext);
- config.setAttribute("DefaultTopicJNDIContext",
- defaultTopicJNDIContext == null? "/topic" : defaultTopicJNDIContext);
+ config.setAttribute("DefaultQueueJNDIContext", defaultQueueJNDIContext == null ? "/queue"
+ : defaultQueueJNDIContext);
+ config.setAttribute("DefaultTopicJNDIContext", defaultTopicJNDIContext == null ? "/topic"
+ : defaultTopicJNDIContext);
}
// Private --------------------------------------------------------------------------------------
- private void overrideAttributes(ObjectName on, ServiceAttributeOverrides attrOverrides)
- throws Exception
+ private void overrideAttributes(ObjectName on, ServiceAttributeOverrides attrOverrides) throws Exception
{
if (attrOverrides == null)
{
@@ -955,7 +1085,7 @@
Map sao = attrOverrides.get(on);
- for(Iterator i = sao.entrySet().iterator(); i.hasNext();)
+ for (Iterator i = sao.entrySet().iterator(); i.hasNext();)
{
Map.Entry entry = (Map.Entry)i.next();
String attrName = (String)entry.getKey();
Modified: branches/Branch_1_4/src/main/org/jboss/jms/server/destination/DestinationServiceSupport.java
===================================================================
--- branches/Branch_1_4/src/main/org/jboss/jms/server/destination/DestinationServiceSupport.java 2008-09-24 23:08:48 UTC (rev 5023)
+++ branches/Branch_1_4/src/main/org/jboss/jms/server/destination/DestinationServiceSupport.java 2008-09-25 04:52:34 UTC (rev 5024)
@@ -1,8 +1,5 @@
/**
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
+ * JBoss, Home of Professional Open Source Distributable under LGPL license. See terms of license at gnu.org.
*/
package org.jboss.jms.server.destination;
@@ -26,16 +23,13 @@
import org.w3c.dom.Element;
/**
- * The base of a JBoss Messaging destination service. Both deployed or programatically created
- * destinations will eventually get one of these.
- *
+ * The base of a JBoss Messaging destination service. Both deployed or programatically created destinations will
+ * eventually get one of these.
+ *
* @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
* @author <a href="mailto:alex.fu at novell.com">Alex Fu</a>
- *
- * @version <tt>$Revision$</tt>
- *
- * $Id$
+ * @version <tt>$Revision$</tt> $Id$
*/
public abstract class DestinationServiceSupport extends ServiceMBeanSupport implements DestinationMBean
{
@@ -46,98 +40,110 @@
// Attributes ----------------------------------------------------
private ObjectName serverPeerObjectName;
-
+
private ObjectName dlqObjectName;
-
+
private ObjectName expiryQueueObjectName;
-
+
protected boolean started = false;
-
+
protected ManagedDestination destination;
-
+
protected ServerPeer serverPeer;
-
+
protected int nodeId;
-
+
private boolean createdProgrammatically;
-
-
+
// Constructors --------------------------------------------------
-
+
public DestinationServiceSupport(boolean createdProgrammatically)
{
- this.createdProgrammatically = createdProgrammatically;
+ this.createdProgrammatically = createdProgrammatically;
}
-
+
public DestinationServiceSupport()
{
}
-
+
// ServerPlugin implementation ------------------------------------------
-
+
public MessagingComponent getInstance()
{
return destination;
}
// ServiceMBeanSupport overrides -----------------------------------
-
+
public synchronized void startService() throws Exception
{
super.startService();
-
+
try
{
serverPeer = (ServerPeer)JMXAccessor.getJMXAttributeOverSecurity(server, serverPeerObjectName, "Instance");
-
+
destination.setServerPeer(serverPeer);
-
+
nodeId = serverPeer.getServerPeerID();
-
+
String name = null;
-
+
if (serviceName != null)
{
name = serviceName.getKeyProperty("name");
}
-
+
if (name == null || name.length() == 0)
{
- throw new IllegalStateException( "The " + (isQueue() ? "queue" : "topic") + " " +
- "name was not properly set in the service's" +
- "ObjectName");
- }
-
- destination.setName(name);
- //must be set after the peer is set on the destination.
- //setMaxSizeForQueues must be called always when setting
- //max Size
- //http://jira.jboss.com/jira/browse/JBMESSAGING-1075
+ throw new IllegalStateException("The " + (isQueue() ? "queue" : "topic") +
+ " " +
+ "name was not properly set in the service's" +
+ "ObjectName");
+ }
+
+ destination.setName(name);
+ // must be set after the peer is set on the destination.
+ // setMaxSizeForQueues must be called always when setting
+ // max Size
+ // http://jira.jboss.com/jira/browse/JBMESSAGING-1075
this.setMaxSizeForQueues();
// http://jira.jboss.com/jira/browse/JBMESSAGING-976
if (destination.getSecurityConfig() != null)
{
- serverPeer.getSecurityManager().setSecurityConfig(isQueue(), destination.getName(), destination.getSecurityConfig());
+ serverPeer.getSecurityManager().setSecurityConfig(isQueue(),
+ destination.getName(),
+ destination.getSecurityConfig());
}
+
+ // //https://jira.jboss.org/jira/browse/JBMESSAGING-1374
+ if (dlqObjectName != null)
+ {
+ setDLQ(dlqObjectName);
+ }
+ if (expiryQueueObjectName != null)
+ {
+ setExpiryQueue(expiryQueueObjectName);
+ }
}
catch (Throwable t)
{
ExceptionUtil.handleJMXInvocation(t, this + " startService");
- }
+ }
}
-
+
public synchronized void stopService() throws Exception
{
- super.stopService();
+ super.stopService();
}
-
+
// JMX managed attributes ----------------------------------------
-
+
public String getName()
{
return destination.getName();
}
-
+
public String getJNDIName()
{
return destination.getJndiName();
@@ -152,8 +158,8 @@
log.warn("Cannot change the value of the JNDI name after initialization!");
return;
}
-
- destination.setJndiName(jndiName);
+
+ destination.setJndiName(jndiName);
}
catch (Throwable t)
{
@@ -165,8 +171,7 @@
{
if (started)
{
- log.warn("Cannot change the value of associated " +
- "server's ObjectName after initialization!");
+ log.warn("Cannot change the value of associated " + "server's ObjectName after initialization!");
return;
}
@@ -177,56 +182,56 @@
{
return serverPeerObjectName;
}
-
+
public void setDLQ(ObjectName on) throws Exception
{
dlqObjectName = on;
-
+
ManagedQueue dest = null;
-
+
try
{
-
+
try
- {
- dest = (ManagedQueue)JMXAccessor.getJMXAttributeOverSecurity(server,dlqObjectName, "Instance" );
+ {
+ dest = (ManagedQueue)JMXAccessor.getJMXAttributeOverSecurity(server, dlqObjectName, "Instance");
}
catch (InstanceNotFoundException e)
{
- //Ok
+ // Ok
}
- destination.setDLQ(dest);
+ destination.setDLQ(dest);
}
catch (Throwable t)
{
throw ExceptionUtil.handleJMXInvocation(t, " setDLQ");
}
}
-
+
public ObjectName getDLQ()
{
return dlqObjectName;
}
-
+
public void setExpiryQueue(ObjectName on) throws Exception
{
expiryQueueObjectName = on;
-
+
ManagedQueue dest = null;
-
+
try
- {
+ {
try
- {
- dest = (ManagedQueue)JMXAccessor.getJMXAttributeOverSecurity(server,expiryQueueObjectName, "Instance" );
+ {
+ dest = (ManagedQueue)JMXAccessor.getJMXAttributeOverSecurity(server, expiryQueueObjectName, "Instance");
}
catch (InstanceNotFoundException e)
{
- //Ok
+ // Ok
}
-
+
destination.setExpiryQueue(dest);
}
catch (Throwable t)
@@ -234,62 +239,63 @@
throw ExceptionUtil.handleJMXInvocation(t, this + " setExpiryQueue");
}
}
-
+
public ObjectName getExpiryQueue()
{
return expiryQueueObjectName;
}
-
+
public long getRedeliveryDelay()
{
return destination.getRedeliveryDelay();
}
-
+
public void setRedeliveryDelay(long delay)
{
destination.setRedeliveryDelay(delay);
}
-
+
public int getMaxSize()
{
return destination.getMaxSize();
}
-
+
/**
- * This is post startup processing for MaxSize for Queues. This can also be set during runtime,
- * given that the destination service is started. Setting max size requires
- * that the peer be setup. http://jira.jboss.com/jira/browse/JBMESSAGING-1075
- * @throws Exception if the post office can't be reached.
+ * This is post startup processing for MaxSize for Queues. This can also be set during runtime, given that the
+ * destination service is started. Setting max size requires that the peer be setup.
+ * http://jira.jboss.com/jira/browse/JBMESSAGING-1075
+ *
+ * @throws Exception if the post office can't be reached.
*/
private void setMaxSizeForQueues() throws Exception
{
- Condition cond = new JMSCondition(isQueue(), this.getName());
- PostOffice postOffice = serverPeer.getPostOfficeInstance();
- Collection subs = postOffice.getQueuesForCondition(cond, true);
- Iterator iter = subs.iterator();
- while (iter.hasNext())
- {
- Queue queue = (Queue)iter.next();
- queue.setMaxSize(this.getMaxSize());
- }
+ Condition cond = new JMSCondition(isQueue(), this.getName());
+ PostOffice postOffice = serverPeer.getPostOfficeInstance();
+ Collection subs = postOffice.getQueuesForCondition(cond, true);
+ Iterator iter = subs.iterator();
+ while (iter.hasNext())
+ {
+ Queue queue = (Queue)iter.next();
+ queue.setMaxSize(this.getMaxSize());
+ }
}
-
+
public void setMaxSize(int maxSize) throws Exception
{
- destination.setMaxSize(maxSize);
- //added so that max size can be changed on the fly
- //http://jira.jboss.com/jira/browse/JBMESSAGING-1075
- if(started)
+ destination.setMaxSize(maxSize);
+ // added so that max size can be changed on the fly
+ // http://jira.jboss.com/jira/browse/JBMESSAGING-1075
+ if (started)
{
- this.setMaxSizeForQueues();
+ this.setMaxSizeForQueues();
}
}
-
+
public Element getSecurityConfig()
{
return destination.getSecurityConfig();
}
-
+
public void setSecurityConfig(Element securityConfig) throws Exception
{
try
@@ -297,9 +303,9 @@
if (started)
{
// push security update to the server
- serverPeer.getSecurityManager().setSecurityConfig(isQueue(), destination.getName(), securityConfig);
+ serverPeer.getSecurityManager().setSecurityConfig(isQueue(), destination.getName(), securityConfig);
}
-
+
destination.setSecurityConfig(securityConfig);
}
catch (Throwable t)
@@ -310,6 +316,7 @@
/**
* Get in-memory message limit
+ *
* @return message limit
*/
public int getFullSize()
@@ -319,6 +326,7 @@
/**
* Set in-memory message limit when destination is stopped.
+ *
* @param fullSize the message limit
*/
public void setFullSize(int fullSize)
@@ -327,12 +335,13 @@
{
log.warn("FullSize can only be changed when destination is stopped");
return;
- }
+ }
destination.setFullSize(fullSize);
}
/**
* Get paging size
+ *
* @return paging size
*/
public int getPageSize()
@@ -342,6 +351,7 @@
/**
* Set paging size when destination is stopped.
+ *
* @param pageSize the paging size
*/
public void setPageSize(int pageSize)
@@ -356,6 +366,7 @@
/**
* Get write-cache size
+ *
* @return cache size
*/
public int getDownCacheSize()
@@ -365,6 +376,7 @@
/**
* Set write-cache size when destination is stopped.
+ *
* @param downCacheSize the cache size
*/
public void setDownCacheSize(int downCacheSize)
@@ -376,12 +388,12 @@
}
destination.setDownCacheSize(downCacheSize);
}
-
+
public boolean isClustered()
{
return destination.isClustered();
}
-
+
public void setClustered(boolean clustered)
{
if (started)
@@ -391,36 +403,35 @@
}
destination.setClustered(clustered);
}
-
+
public boolean isCreatedProgrammatically()
{
return createdProgrammatically;
}
-
+
public int getMessageCounterHistoryDayLimit()
{
return destination.getMessageCounterHistoryDayLimit();
}
-
+
public void setMessageCounterHistoryDayLimit(int limit) throws Exception
{
destination.setMessageCounterHistoryDayLimit(limit);
}
-
+
public int getMaxDeliveryAttempts()
{
return destination.getMaxDeliveryAttempts();
}
-
+
public void setMaxDeliveryAttempts(int maxDeliveryAttempts)
{
destination.setMaxDeliveryAttempts(maxDeliveryAttempts);
}
-
+
// JMX managed operations ----------------------------------------
-
+
public abstract void removeAllMessages() throws Exception;
-
// Public --------------------------------------------------------
@@ -472,7 +483,7 @@
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
-
+
/**
* List message counters as HTML table
*
@@ -482,61 +493,60 @@
{
if (counters == null)
return null;
-
- String ret = "<table width=\"100%\" border=\"1\" cellpadding=\"1\" cellspacing=\"1\">" +
- "<tr>" +
- "<th>Type</th>" +
- "<th>Name</th>" +
- "<th>Subscription</th>" +
- "<th>Durable</th>" +
- "<th>Count</th>" +
- "<th>CountDelta</th>" +
- "<th>Depth</th>" +
- "<th>DepthDelta</th>" +
- "<th>Last Add</th>" +
- "</tr>";
-
- for( int i=0; i<counters.length; i++ )
+
+ String ret = "<table width=\"100%\" border=\"1\" cellpadding=\"1\" cellspacing=\"1\">" + "<tr>"
+ + "<th>Type</th>"
+ + "<th>Name</th>"
+ + "<th>Subscription</th>"
+ + "<th>Durable</th>"
+ + "<th>Count</th>"
+ + "<th>CountDelta</th>"
+ + "<th>Depth</th>"
+ + "<th>DepthDelta</th>"
+ + "<th>Last Add</th>"
+ + "</tr>";
+
+ for (int i = 0; i < counters.length; i++)
{
- String data = counters[i].getCounterAsString();
- StringTokenizer token = new StringTokenizer( data, ",");
- String value;
-
- ret += "<tr bgcolor=\"#" + ( (i%2)==0 ? "FFFFFF" : "F0F0F0") + "\">";
+ String data = counters[i].getCounterAsString();
+ StringTokenizer token = new StringTokenizer(data, ",");
+ String value;
+ ret += "<tr bgcolor=\"#" + ((i % 2) == 0 ? "FFFFFF" : "F0F0F0") + "\">";
+
ret += "<td>" + token.nextToken() + "</td>"; // type
ret += "<td>" + token.nextToken() + "</td>"; // name
ret += "<td>" + token.nextToken() + "</td>"; // subscription
ret += "<td>" + token.nextToken() + "</td>"; // durable
ret += "<td>" + token.nextToken() + "</td>"; // count
-
+
value = token.nextToken(); // countDelta
- if( value.equalsIgnoreCase("0") )
- value = "-";
-
+ if (value.equalsIgnoreCase("0"))
+ value = "-";
+
ret += "<td>" + value + "</td>";
-
+
ret += "<td>" + token.nextToken() + "</td>"; // depth
-
+
value = token.nextToken(); // depthDelta
-
- if( value.equalsIgnoreCase("0") )
- value = "-";
-
+
+ if (value.equalsIgnoreCase("0"))
+ value = "-";
+
ret += "<td>" + value + "</td>";
ret += "<td>" + token.nextToken() + "</td>"; // date last add
ret += "</tr>";
}
-
+
ret += "</table>";
-
+
return ret;
- }
-
+ }
+
/**
* List destination message counter history as HTML table
*
@@ -546,60 +556,57 @@
{
if (counters == null)
return null;
-
- String ret = "";
-
- for( int i=0; i<counters.length; i++ )
+
+ String ret = "";
+
+ for (int i = 0; i < counters.length; i++)
{
// destination name
- ret += ( counters[i].getDestinationTopic() ? "Topic '" : "Queue '" );
+ ret += (counters[i].getDestinationTopic() ? "Topic '" : "Queue '");
ret += counters[i].getDestinationName() + "'";
-
- if( counters[i].getDestinationSubscription() != null )
+
+ if (counters[i].getDestinationSubscription() != null)
ret += "Subscription '" + counters[i].getDestinationSubscription() + "'";
-
-
+
// table header
- ret += "<table width=\"100%\" border=\"1\" cellpadding=\"1\" cellspacing=\"1\">" +
- "<tr>" +
- "<th>Date</th>";
+ ret += "<table width=\"100%\" border=\"1\" cellpadding=\"1\" cellspacing=\"1\">" + "<tr>" + "<th>Date</th>";
- for( int j = 0; j < 24; j++ )
+ for (int j = 0; j < 24; j++)
ret += "<th width=\"4%\">" + j + "</th>";
ret += "<th>Total</th></tr>";
- // get history data as CSV string
- StringTokenizer tokens = new StringTokenizer( counters[i].getHistoryAsString(), ",\n");
-
+ // get history data as CSV string
+ StringTokenizer tokens = new StringTokenizer(counters[i].getHistoryAsString(), ",\n");
+
// get history day count
- int days = Integer.parseInt( tokens.nextToken() );
-
- for( int j=0; j<days; j++ )
+ int days = Integer.parseInt(tokens.nextToken());
+
+ for (int j = 0; j < days; j++)
{
- // next day counter row
- ret += "<tr bgcolor=\"#" + ((j%2)==0 ? "FFFFFF" : "F0F0F0") + "\">";
-
- // date
+ // next day counter row
+ ret += "<tr bgcolor=\"#" + ((j % 2) == 0 ? "FFFFFF" : "F0F0F0") + "\">";
+
+ // date
ret += "<td>" + tokens.nextToken() + "</td>";
-
+
// 24 hour counters
int total = 0;
-
- for( int k=0; k<24; k++ )
+
+ for (int k = 0; k < 24; k++)
{
- int value = Integer.parseInt( tokens.nextToken().trim() );
-
- if( value == -1 )
+ int value = Integer.parseInt(tokens.nextToken().trim());
+
+ if (value == -1)
{
- ret += "<td></td>";
- }
+ ret += "<td></td>";
+ }
else
{
- ret += "<td>" + value + "</td>";
-
- total += value;
- }
+ ret += "<td>" + value + "</td>";
+
+ total += value;
+ }
}
ret += "<td>" + total + "</td></tr>";
Modified: branches/Branch_1_4/tests/etc/container.xml
===================================================================
--- branches/Branch_1_4/tests/etc/container.xml 2008-09-24 23:08:48 UTC (rev 5023)
+++ branches/Branch_1_4/tests/etc/container.xml 2008-09-25 04:52:34 UTC (rev 5024)
@@ -35,7 +35,7 @@
<url>jdbc:mysql://localhost/messaging</url>
<driver>com.mysql.jdbc.Driver</driver>
<isolation>TRANSACTION_READ_COMMITTED</isolation>
- <username>root</username>
+ <username>sa</username>
</database-configuration>
Modified: branches/Branch_1_4/tests/src/org/jboss/test/messaging/jms/DLQTest.java
===================================================================
--- branches/Branch_1_4/tests/src/org/jboss/test/messaging/jms/DLQTest.java 2008-09-24 23:08:48 UTC (rev 5023)
+++ branches/Branch_1_4/tests/src/org/jboss/test/messaging/jms/DLQTest.java 2008-09-25 04:52:34 UTC (rev 5024)
@@ -1,23 +1,13 @@
/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ * JBoss, Home of Professional Open Source Copyright 2005, JBoss Inc., and individual contributors as indicated by the
+ * @authors tag. See the copyright.txt in the distribution for a full listing of individual contributors. This is free
+ * software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+ * This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details. You should have received a copy of the GNU Lesser General Public License along with this software; if not,
+ * write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
*/
package org.jboss.test.messaging.jms;
@@ -31,6 +21,7 @@
import javax.jms.MessageConsumer;
import javax.jms.MessageListener;
import javax.jms.MessageProducer;
+import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.jms.Topic;
@@ -43,12 +34,9 @@
/**
* A DLQTest
- *
+ *
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- *
+ * @version <tt>$Revision$</tt> $Id$
*/
public class DLQTest extends JMSTestCase
{
@@ -73,31 +61,33 @@
{
return;
}
-
+
try
{
- ServerManagement.deployQueue("DLQ");
-
+ ServerManagement.deployQueue("DLQ");
+
ObjectName serverPeerObjectName = ServerManagement.getServerPeerObjectName();
-
+
ObjectName dlqObjectName = (ObjectName)ServerManagement.getAttribute(serverPeerObjectName, "DefaultDLQ");
-
+
assertNotNull(dlqObjectName);
-
+
String name = (String)ServerManagement.getAttribute(dlqObjectName, "Name");
-
+
assertNotNull(name);
-
+
assertEquals("DLQ", name);
String jndiName = (String)ServerManagement.getAttribute(dlqObjectName, "JNDIName");
-
+
assertNotNull(jndiName);
-
+
assertEquals("/queue/DLQ", jndiName);
-
- org.jboss.messaging.core.contract.Queue dlq = ServerManagement.getServer().getServerPeer().getDefaultDLQInstance();
+ org.jboss.messaging.core.contract.Queue dlq = ServerManagement.getServer()
+ .getServerPeer()
+ .getDefaultDLQInstance();
+
assertNotNull(dlq);
JBossQueue q = (JBossQueue)ic.lookup("/queue/DLQ");
@@ -118,9 +108,11 @@
{
return;
}
-
- org.jboss.messaging.core.contract.Queue dlq = ServerManagement.getServer().getServerPeer().getDefaultDLQInstance();
+ org.jboss.messaging.core.contract.Queue dlq = ServerManagement.getServer()
+ .getServerPeer()
+ .getDefaultDLQInstance();
+
assertNull(dlq);
try
@@ -131,168 +123,170 @@
}
catch (NameNotFoundException e)
{
- //Ok
+ // Ok
}
}
-
+
public void testDefaultAndOverrideDLQ() throws Exception
{
if (ServerManagement.isRemote())
{
return;
}
-
+
final int NUM_MESSAGES = 5;
-
+
final int MAX_DELIVERIES = 8;
-
- ObjectName serverPeerObjectName = ServerManagement.getServerPeerObjectName();
-
- String testQueueObjectName = "jboss.messaging.destination:service=Queue,name=Queue1";
-
- Connection conn = null;
-
+
+ ObjectName serverPeerObjectName = ServerManagement.getServerPeerObjectName();
+
+ String testQueueObjectName = "jboss.messaging.destination:service=Queue,name=Queue1";
+
+ Connection conn = null;
+
try
- {
- String defaultDLQObjectName = "jboss.messaging.destination:service=Queue,name=Queue2";
-
- String overrideDLQObjectName = "jboss.messaging.destination:service=Queue,name=Queue3";
-
- ServerManagement.setAttribute(serverPeerObjectName, "DefaultMaxDeliveryAttempts", String.valueOf(MAX_DELIVERIES));
-
- ServerManagement.setAttribute(serverPeerObjectName, "DefaultDLQ", defaultDLQObjectName);
-
- ServerManagement.setAttribute(new ObjectName(testQueueObjectName), "DLQ", "");
-
+ {
+ String defaultDLQObjectName = "jboss.messaging.destination:service=Queue,name=Queue2";
+
+ String overrideDLQObjectName = "jboss.messaging.destination:service=Queue,name=Queue3";
+
+ ServerManagement.setAttribute(serverPeerObjectName,
+ "DefaultMaxDeliveryAttempts",
+ String.valueOf(MAX_DELIVERIES));
+
+ ServerManagement.setAttribute(serverPeerObjectName, "DefaultDLQ", defaultDLQObjectName);
+
+ ServerManagement.setAttribute(new ObjectName(testQueueObjectName), "DLQ", "");
+
conn = cf.createConnection();
-
- {
+
+ {
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
+
MessageProducer prod = sess.createProducer(queue1);
-
+
for (int i = 0; i < NUM_MESSAGES; i++)
{
TextMessage tm = sess.createTextMessage("Message:" + i);
-
+
prod.send(tm);
}
-
+
Session sess2 = conn.createSession(false, Session.CLIENT_ACKNOWLEDGE);
-
+
MessageConsumer cons = sess2.createConsumer(queue1);
-
+
conn.start();
-
- for (int i = 0; i < MAX_DELIVERIES; i++)
+
+ for (int i = 0; i < MAX_DELIVERIES; i++)
{
for (int j = 0; j < NUM_MESSAGES; j++)
{
TextMessage tm = (TextMessage)cons.receive(1000);
-
+
assertNotNull(tm);
-
+
assertEquals("Message:" + j, tm.getText());
}
-
+
sess2.recover();
}
-
- //Prompt them to go to DLQ
+
+ // Prompt them to go to DLQ
cons.receive(100);
-
- //At this point all the messages have been delivered exactly MAX_DELIVERIES times
-
+
+ // At this point all the messages have been delivered exactly MAX_DELIVERIES times
+
checkEmpty(queue1);
-
- //Now should be in default dlq
-
+
+ // Now should be in default dlq
+
MessageConsumer cons3 = sess.createConsumer(queue2);
-
+
for (int i = 0; i < NUM_MESSAGES; i++)
{
TextMessage tm = (TextMessage)cons3.receive(1000);
-
+
assertNotNull(tm);
-
+
assertEquals("Message:" + i, tm.getText());
}
-
+
conn.close();
}
-
-
+
{
- //Now try with overriding the default dlq
-
+ // Now try with overriding the default dlq
+
conn = cf.createConnection();
-
+
ServerManagement.setAttribute(new ObjectName(testQueueObjectName), "DLQ", overrideDLQObjectName);
-
+
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
+
MessageProducer prod = sess.createProducer(queue1);
-
+
for (int i = 0; i < NUM_MESSAGES; i++)
{
TextMessage tm = sess.createTextMessage("Message:" + i);
-
+
prod.send(tm);
}
-
+
Session sess2 = conn.createSession(false, Session.CLIENT_ACKNOWLEDGE);
-
+
MessageConsumer cons = sess2.createConsumer(queue1);
-
+
conn.start();
-
- for (int i = 0; i < MAX_DELIVERIES; i++)
+
+ for (int i = 0; i < MAX_DELIVERIES; i++)
{
for (int j = 0; j < NUM_MESSAGES; j++)
{
TextMessage tm = (TextMessage)cons.receive(1000);
-
+
assertNotNull(tm);
-
+
assertEquals("Message:" + j, tm.getText());
}
-
+
sess2.recover();
}
-
+
cons.receive(100);
-
- //At this point all the messages have been delivered exactly MAX_DELIVERIES times
-
+
+ // At this point all the messages have been delivered exactly MAX_DELIVERIES times
+
checkEmpty(queue1);
-
- //Now should be in override dlq
-
+
+ // Now should be in override dlq
+
MessageConsumer cons3 = sess.createConsumer(queue3);
-
+
for (int i = 0; i < NUM_MESSAGES; i++)
{
TextMessage tm = (TextMessage)cons3.receive(1000);
-
+
assertNotNull(tm);
-
+
assertEquals("Message:" + i, tm.getText());
}
}
}
finally
{
- ServerManagement.setAttribute(serverPeerObjectName, "DefaultDLQ", "jboss.messaging.destination:service=Queue,name=DLQ");
-
- ServerManagement.setAttribute(new ObjectName(testQueueObjectName), "DLQ", "");
-
+ ServerManagement.setAttribute(serverPeerObjectName,
+ "DefaultDLQ",
+ "jboss.messaging.destination:service=Queue,name=DLQ");
+
+ ServerManagement.setAttribute(new ObjectName(testQueueObjectName), "DLQ", "");
+
if (conn != null)
{
conn.close();
}
}
}
-
public void testWithMessageListenerPersistent() throws Exception
{
@@ -313,7 +307,7 @@
{
testWithReceiveClientAck(false);
}
-
+
public void testWithReceiveTransactionalPersistent() throws Exception
{
this.testWithReceiveTransactional(true);
@@ -322,43 +316,47 @@
public void testWithReceiveTransactionalNonPersistent() throws Exception
{
testWithReceiveTransactional(false);
- }
-
+ }
+
public void testHeadersSet() throws Exception
{
Connection conn = null;
-
+
try
- {
- ObjectName serverPeerObjectName = ServerManagement.getServerPeerObjectName();
-
- ServerManagement.setAttribute(serverPeerObjectName, "DefaultDLQ", "jboss.messaging.destination:service=Queue,name=Queue2");
+ {
+ ObjectName serverPeerObjectName = ServerManagement.getServerPeerObjectName();
- final int MAX_DELIVERIES = 16;
-
- final int NUM_MESSAGES = 5;
-
- ServerManagement.setAttribute(serverPeerObjectName, "DefaultMaxDeliveryAttempts", String.valueOf(MAX_DELIVERIES));
-
- int maxRedeliveryAttempts =
- ((Integer)ServerManagement.getAttribute(serverPeerObjectName, "DefaultMaxDeliveryAttempts")).intValue();
-
- assertEquals(MAX_DELIVERIES, maxRedeliveryAttempts);
+ ServerManagement.setAttribute(serverPeerObjectName,
+ "DefaultDLQ",
+ "jboss.messaging.destination:service=Queue,name=Queue2");
+ final int MAX_DELIVERIES = 16;
+
+ final int NUM_MESSAGES = 5;
+
+ ServerManagement.setAttribute(serverPeerObjectName,
+ "DefaultMaxDeliveryAttempts",
+ String.valueOf(MAX_DELIVERIES));
+
+ int maxRedeliveryAttempts = ((Integer)ServerManagement.getAttribute(serverPeerObjectName,
+ "DefaultMaxDeliveryAttempts")).intValue();
+
+ assertEquals(MAX_DELIVERIES, maxRedeliveryAttempts);
+
conn = cf.createConnection();
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer prod = sess.createProducer(queue1);
-
- Map origIds = new HashMap();
+ Map origIds = new HashMap();
+
for (int i = 0; i < NUM_MESSAGES; i++)
{
TextMessage tm = sess.createTextMessage("Message:" + i);
prod.send(tm);
-
+
origIds.put(tm.getText(), tm.getJMSMessageID());
}
@@ -368,7 +366,7 @@
conn.start();
- for (int i = 0; i < MAX_DELIVERIES; i++)
+ for (int i = 0; i < MAX_DELIVERIES; i++)
{
for (int j = 0; j < NUM_MESSAGES; j++)
{
@@ -381,133 +379,230 @@
sess2.rollback();
}
-
- //At this point all the messages have been delivered exactly MAX_DELIVERIES times - this is ok
- //they haven't exceeded max delivery attempts so shouldn't be in the DLQ - let's check
-
+
+ // At this point all the messages have been delivered exactly MAX_DELIVERIES times - this is ok
+ // they haven't exceeded max delivery attempts so shouldn't be in the DLQ - let's check
+
checkEmpty(queue2);
-
+
// So let's try and consume them - this should cause them to go to the DLQ - since they
// will then exceed max delivery attempts
Message m = cons.receive(100);
-
+
assertNull(m);
-
- //All the messages should now be in the DLQ
-
- MessageConsumer cons3 = sess.createConsumer(queue2);
-
+
+ // All the messages should now be in the DLQ
+
+ MessageConsumer cons3 = sess.createConsumer(queue2);
+
for (int i = 0; i < NUM_MESSAGES; i++)
{
TextMessage tm = (TextMessage)cons3.receive(1000);
-
+
assertNotNull(tm);
assertEquals("Message:" + i, tm.getText());
-
+
// Check the headers
- String origDest =
- tm.getStringProperty(JBossMessage.JBOSS_MESSAGING_ORIG_DESTINATION);
-
- String origMessageId =
- tm.getStringProperty(JBossMessage.JBOSS_MESSAGING_ORIG_MESSAGE_ID);
-
+ String origDest = tm.getStringProperty(JBossMessage.JBOSS_MESSAGING_ORIG_DESTINATION);
+
+ String origMessageId = tm.getStringProperty(JBossMessage.JBOSS_MESSAGING_ORIG_MESSAGE_ID);
+
assertEquals(queue1.toString(), origDest);
-
+
String origId = (String)origIds.get(tm.getText());
-
+
assertEquals(origId, origMessageId);
}
}
finally
{
- if (conn != null) conn.close();
+ if (conn != null)
+ conn.close();
}
}
public void testOverrideDefaultMaxDeliveryAttemptsForQueue() throws Exception
- {
- int md = getDefaultMaxDeliveryAttempts();
- try
- {
- int maxDeliveryAttempts = md - 5;
- setMaxDeliveryAttempts(
- new ObjectName("jboss.messaging.destination:service=Queue,name=Queue1"),
- maxDeliveryAttempts);
- testMaxDeliveryAttempts(queue1, maxDeliveryAttempts, true);
- }
- finally
- {
- setMaxDeliveryAttempts(
- new ObjectName("jboss.messaging.destination:service=Queue,name=Queue1"),
- md);
- }
+ {
+ int md = getDefaultMaxDeliveryAttempts();
+ try
+ {
+ int maxDeliveryAttempts = md - 5;
+ setMaxDeliveryAttempts(new ObjectName("jboss.messaging.destination:service=Queue,name=Queue1"),
+ maxDeliveryAttempts);
+ testMaxDeliveryAttempts(queue1, maxDeliveryAttempts, true);
+ }
+ finally
+ {
+ setMaxDeliveryAttempts(new ObjectName("jboss.messaging.destination:service=Queue,name=Queue1"), md);
+ }
}
public void testOverrideDefaultMaxDeliveryAttemptsForTopic() throws Exception
{
- int md = getDefaultMaxDeliveryAttempts();
- try
- {
- int maxDeliveryAttempts = md - 5;
- setMaxDeliveryAttempts(
- new ObjectName("jboss.messaging.destination:service=Topic,name=Topic1"),
- maxDeliveryAttempts);
-
- testMaxDeliveryAttempts(topic1, maxDeliveryAttempts, false);
- }
- finally
- {
- setMaxDeliveryAttempts(
- new ObjectName("jboss.messaging.destination:service=Queue,name=Queue1"),
- md);
- }
+ int md = getDefaultMaxDeliveryAttempts();
+ try
+ {
+ int maxDeliveryAttempts = md - 5;
+ setMaxDeliveryAttempts(new ObjectName("jboss.messaging.destination:service=Topic,name=Topic1"),
+ maxDeliveryAttempts);
+
+ testMaxDeliveryAttempts(topic1, maxDeliveryAttempts, false);
+ }
+ finally
+ {
+ setMaxDeliveryAttempts(new ObjectName("jboss.messaging.destination:service=Queue,name=Queue1"), md);
+ }
}
-
+
public void testUseDefaultMaxDeliveryAttemptsForQueue() throws Exception
{
- int md = getDefaultMaxDeliveryAttempts();
- try
- {
- setMaxDeliveryAttempts(
- new ObjectName("jboss.messaging.destination:service=Queue,name=Queue1"),
- -1);
-
- // Check that defaultMaxDeliveryAttempts takes effect
- testMaxDeliveryAttempts(queue1, getDefaultMaxDeliveryAttempts(), true);
- }
- finally
- {
- setMaxDeliveryAttempts(
- new ObjectName("jboss.messaging.destination:service=Queue,name=Queue1"),
- md);
- }
+ int md = getDefaultMaxDeliveryAttempts();
+ try
+ {
+ setMaxDeliveryAttempts(new ObjectName("jboss.messaging.destination:service=Queue,name=Queue1"), -1);
+
+ // Check that defaultMaxDeliveryAttempts takes effect
+ testMaxDeliveryAttempts(queue1, getDefaultMaxDeliveryAttempts(), true);
+ }
+ finally
+ {
+ setMaxDeliveryAttempts(new ObjectName("jboss.messaging.destination:service=Queue,name=Queue1"), md);
+ }
}
public void testUseDefaultMaxDeliveryAttemptsForTopic() throws Exception
{
- int md = getDefaultMaxDeliveryAttempts();
- try
- {
- setMaxDeliveryAttempts(
- new ObjectName("jboss.messaging.destination:service=Topic,name=Topic1"),
- -1);
-
- // Check that defaultMaxDeliveryAttempts takes effect
- testMaxDeliveryAttempts(topic1, getDefaultMaxDeliveryAttempts(), false);
- }
- finally
- {
- setMaxDeliveryAttempts(
- new ObjectName("jboss.messaging.destination:service=Queue,name=Queue1"),
- md);
- }
+ int md = getDefaultMaxDeliveryAttempts();
+ try
+ {
+ setMaxDeliveryAttempts(new ObjectName("jboss.messaging.destination:service=Topic,name=Topic1"), -1);
+
+ // Check that defaultMaxDeliveryAttempts takes effect
+ testMaxDeliveryAttempts(topic1, getDefaultMaxDeliveryAttempts(), false);
+ }
+ finally
+ {
+ setMaxDeliveryAttempts(new ObjectName("jboss.messaging.destination:service=Queue,name=Queue1"), md);
+ }
}
-
+
+ // https://jira.jboss.org/jira/browse/JBMESSAGING-1374
+ public void testForwardReferencedDLQ() throws Exception
+ {
+ if (ServerManagement.isRemote())
+ {
+ return;
+ }
+
+ final int NUM_MESSAGES = 5;
+
+ final int MAX_DELIVERIES = 8;
+
+ ObjectName serverPeerObjectName = ServerManagement.getServerPeerObjectName();
+
+ String testQueueName = "testQueue";
+ String testTopicName = "testTopic";
+
+ String testDLQName = "testDLQ";
+ String testExpiryQName = "testExpiryQ";
+
+ Connection conn = null;
+
+ try
+ {
+ ServerManagement.deployQueue("DLQ");
+ ServerManagement.deployQueue("ExpiryQueue");
+
+ ObjectName myQueue = ServerManagement.deployQueueWithDLQnExpiryQ(testQueueName, testDLQName, testExpiryQName);
+ ObjectName myTopic = ServerManagement.deployTopicWithDLQnExpiryQ(testTopicName, testDLQName, testExpiryQName);
+ ObjectName myDLQ = ServerManagement.deployQueueWithoutStart(testDLQName);
+ ObjectName myExpiryQueue = ServerManagement.deployQueueWithoutStart(testExpiryQName);
+
+ assertNotNull(myQueue);
+ assertNotNull(myTopic);
+ assertNotNull(myDLQ);
+ assertNotNull(myExpiryQueue);
+
+ ServerManagement.startDestinationService(new ObjectName[] { myQueue, myTopic, myDLQ, myExpiryQueue });
+
+ ServerManagement.setAttribute(serverPeerObjectName,
+ "DefaultMaxDeliveryAttempts",
+ String.valueOf(MAX_DELIVERIES));
+
+ conn = cf.createConnection();
+
+ {
+ Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ Queue myQRef = (Queue)ic.lookup("/queue/testQueue");
+
+ MessageProducer prod = sess.createProducer(myQRef);
+
+ for (int i = 0; i < NUM_MESSAGES; i++)
+ {
+ TextMessage tm = sess.createTextMessage("Message:" + i);
+
+ prod.send(tm);
+ }
+
+ Session sess2 = conn.createSession(false, Session.CLIENT_ACKNOWLEDGE);
+
+ MessageConsumer cons = sess2.createConsumer(myQRef);
+
+ conn.start();
+
+ for (int i = 0; i < MAX_DELIVERIES; i++)
+ {
+ for (int j = 0; j < NUM_MESSAGES; j++)
+ {
+ TextMessage tm = (TextMessage)cons.receive(1000);
+
+ assertNotNull(tm);
+
+ assertEquals("Message:" + j, tm.getText());
+ }
+
+ sess2.recover();
+ }
+
+ // Prompt them to go to DLQ
+ cons.receive(100);
+
+ // At this point all the messages have been delivered exactly MAX_DELIVERIES times
+
+ checkEmpty(myQRef);
+
+ // Now should be in the dlq
+ Queue myDLQRef = (Queue)ic.lookup("/queue/testDLQ");
+ MessageConsumer cons3 = sess.createConsumer(myDLQRef);
+
+ for (int i = 0; i < NUM_MESSAGES; i++)
+ {
+ TextMessage tm = (TextMessage)cons3.receive(1000);
+
+ assertNotNull(tm);
+
+ assertEquals("Message:" + i, tm.getText());
+ }
+
+ conn.close();
+ }
+ }
+ finally
+ {
+
+ if (conn != null)
+ {
+ conn.close();
+ }
+ }
+ }
+
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
-
+
protected void testWithMessageListener(boolean persistent) throws Exception
{
Connection conn = null;
@@ -515,22 +610,24 @@
try
{
ObjectName serverPeerObjectName = ServerManagement.getServerPeerObjectName();
-
+
final int MAX_DELIVERIES = 16;
-
+
final int NUM_MESSAGES = 5;
-
- ServerManagement.setAttribute(serverPeerObjectName, "DefaultMaxDeliveryAttempts", String.valueOf(MAX_DELIVERIES));
-
- String defaultDLQObjectName = "jboss.messaging.destination:service=Queue,name=Queue2";
-
+
+ ServerManagement.setAttribute(serverPeerObjectName,
+ "DefaultMaxDeliveryAttempts",
+ String.valueOf(MAX_DELIVERIES));
+
+ String defaultDLQObjectName = "jboss.messaging.destination:service=Queue,name=Queue2";
+
ServerManagement.setAttribute(serverPeerObjectName, "DefaultDLQ", defaultDLQObjectName);
-
- int maxRedeliveryAttempts =
- ((Integer)ServerManagement.getAttribute(serverPeerObjectName, "DefaultMaxDeliveryAttempts")).intValue();
-
+
+ int maxRedeliveryAttempts = ((Integer)ServerManagement.getAttribute(serverPeerObjectName,
+ "DefaultMaxDeliveryAttempts")).intValue();
+
assertEquals(MAX_DELIVERIES, maxRedeliveryAttempts);
-
+
conn = cf.createConnection();
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
@@ -538,7 +635,7 @@
MessageProducer prod = sess.createProducer(queue1);
prod.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
-
+
for (int i = 0; i < NUM_MESSAGES; i++)
{
TextMessage tm = sess.createTextMessage("Message:" + i);
@@ -547,9 +644,9 @@
}
MessageConsumer cons = sess.createConsumer(queue1);
-
- FailingMessageListener listener = new FailingMessageListener(MAX_DELIVERIES * NUM_MESSAGES);
+ FailingMessageListener listener = new FailingMessageListener(MAX_DELIVERIES * NUM_MESSAGES);
+
cons.setMessageListener(listener);
conn.start();
@@ -557,9 +654,9 @@
listener.waitForMessages();
assertEquals(MAX_DELIVERIES * NUM_MESSAGES, listener.deliveryCount);
-
- //Message should all be in the dlq - let's check
+ // Message should all be in the dlq - let's check
+
MessageConsumer cons2 = sess.createConsumer(queue2);
for (int i = 0; i < NUM_MESSAGES; i++)
@@ -567,20 +664,20 @@
TextMessage tm = (TextMessage)cons2.receive(1000);
assertNotNull(tm);
-
+
log.info("Got mnessage" + tm);
assertEquals("Message:" + i, tm.getText());
}
-
- checkEmpty(queue1);
+
+ checkEmpty(queue1);
}
finally
{
- if (conn != null) conn.close();
+ if (conn != null)
+ conn.close();
}
}
-
protected void testWithReceiveClientAck(boolean persistent) throws Exception
{
@@ -589,22 +686,24 @@
try
{
ObjectName serverPeerObjectName = ServerManagement.getServerPeerObjectName();
-
+
final int MAX_DELIVERIES = 16;
-
- final int NUM_MESSAGES = 5;
-
- String defaultDLQObjectName = "jboss.messaging.destination:service=Queue,name=Queue2";
-
- ServerManagement.setAttribute(serverPeerObjectName, "DefaultDLQ", defaultDLQObjectName);
-
- ServerManagement.setAttribute(serverPeerObjectName, "DefaultMaxDeliveryAttempts", String.valueOf(MAX_DELIVERIES));
-
- int maxRedeliveryAttempts =
- ((Integer)ServerManagement.getAttribute(serverPeerObjectName, "DefaultMaxDeliveryAttempts")).intValue();
-
+
+ final int NUM_MESSAGES = 5;
+
+ String defaultDLQObjectName = "jboss.messaging.destination:service=Queue,name=Queue2";
+
+ ServerManagement.setAttribute(serverPeerObjectName, "DefaultDLQ", defaultDLQObjectName);
+
+ ServerManagement.setAttribute(serverPeerObjectName,
+ "DefaultMaxDeliveryAttempts",
+ String.valueOf(MAX_DELIVERIES));
+
+ int maxRedeliveryAttempts = ((Integer)ServerManagement.getAttribute(serverPeerObjectName,
+ "DefaultMaxDeliveryAttempts")).intValue();
+
assertEquals(MAX_DELIVERIES, maxRedeliveryAttempts);
-
+
conn = cf.createConnection();
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
@@ -612,7 +711,7 @@
MessageProducer prod = sess.createProducer(queue1);
prod.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
-
+
for (int i = 0; i < NUM_MESSAGES; i++)
{
TextMessage tm = sess.createTextMessage("Message:" + i);
@@ -626,7 +725,7 @@
conn.start();
- for (int i = 0; i < MAX_DELIVERIES; i++)
+ for (int i = 0; i < MAX_DELIVERIES; i++)
{
for (int j = 0; j < NUM_MESSAGES; j++)
{
@@ -639,46 +738,47 @@
sess2.recover();
}
-
- //At this point all the messages have been delivered exactly MAX_DELIVERIES times - this is ok
- //they haven't exceeded max delivery attempts so shouldn't be in the DLQ - let's check
-
+
+ // At this point all the messages have been delivered exactly MAX_DELIVERIES times - this is ok
+ // they haven't exceeded max delivery attempts so shouldn't be in the DLQ - let's check
+
checkEmpty(queue2);
-
- //So let's try and consume them - this should cause them to go to the DLQ - since they will then exceed max
- //delivery attempts
-
+
+ // So let's try and consume them - this should cause them to go to the DLQ - since they will then exceed max
+ // delivery attempts
+
Message m = cons.receive(100);
-
+
assertNull(m);
-
- //Now, all the messages should now be in the DLQ
-
+
+ // Now, all the messages should now be in the DLQ
+
MessageConsumer cons3 = sess.createConsumer(queue2);
-
+
for (int i = 0; i < NUM_MESSAGES; i++)
{
TextMessage tm = (TextMessage)cons3.receive(1000);
-
+
assertNotNull(tm);
assertEquals("Message:" + i, tm.getText());
}
- //No more should be available
-
+ // No more should be available
+
cons.close();
-
+
checkEmpty(queue1);
}
finally
{
ServerManagement.undeployQueue("DLQ");
- if (conn != null) conn.close();
+ if (conn != null)
+ conn.close();
}
}
-
+
protected void testWithReceiveTransactional(boolean persistent) throws Exception
{
Connection conn = null;
@@ -686,22 +786,24 @@
try
{
ObjectName serverPeerObjectName = ServerManagement.getServerPeerObjectName();
-
+
final int MAX_DELIVERIES = 16;
-
- final int NUM_MESSAGES = 5;
-
- ServerManagement.setAttribute(serverPeerObjectName, "DefaultMaxDeliveryAttempts", String.valueOf(MAX_DELIVERIES));
-
- String defaultDLQObjectName = "jboss.messaging.destination:service=Queue,name=Queue2";
-
- ServerManagement.setAttribute(serverPeerObjectName, "DefaultDLQ", defaultDLQObjectName);
-
- int maxRedeliveryAttempts =
- ((Integer)ServerManagement.getAttribute(serverPeerObjectName, "DefaultMaxDeliveryAttempts")).intValue();
-
+
+ final int NUM_MESSAGES = 5;
+
+ ServerManagement.setAttribute(serverPeerObjectName,
+ "DefaultMaxDeliveryAttempts",
+ String.valueOf(MAX_DELIVERIES));
+
+ String defaultDLQObjectName = "jboss.messaging.destination:service=Queue,name=Queue2";
+
+ ServerManagement.setAttribute(serverPeerObjectName, "DefaultDLQ", defaultDLQObjectName);
+
+ int maxRedeliveryAttempts = ((Integer)ServerManagement.getAttribute(serverPeerObjectName,
+ "DefaultMaxDeliveryAttempts")).intValue();
+
assertEquals(MAX_DELIVERIES, maxRedeliveryAttempts);
-
+
conn = cf.createConnection();
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
@@ -709,7 +811,7 @@
MessageProducer prod = sess.createProducer(queue1);
prod.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
-
+
for (int i = 0; i < NUM_MESSAGES; i++)
{
TextMessage tm = sess.createTextMessage("Message:" + i);
@@ -723,7 +825,7 @@
conn.start();
- for (int i = 0; i < MAX_DELIVERIES; i++)
+ for (int i = 0; i < MAX_DELIVERIES; i++)
{
for (int j = 0; j < NUM_MESSAGES; j++)
{
@@ -736,86 +838,85 @@
sess2.rollback();
}
-
- //At this point all the messages have been delivered exactly MAX_DELIVERIES times - this is ok
- //they haven't exceeded max delivery attempts so shouldn't be in the DLQ - let's check
-
+
+ // At this point all the messages have been delivered exactly MAX_DELIVERIES times - this is ok
+ // they haven't exceeded max delivery attempts so shouldn't be in the DLQ - let's check
+
checkEmpty(queue2);
-
- //So let's try and consume them - this should cause them to go to the DLQ - since they will then exceed max
- //delivery attempts
+
+ // So let's try and consume them - this should cause them to go to the DLQ - since they will then exceed max
+ // delivery attempts
Message m = cons.receive(100);
-
+
assertNull(m);
-
- //All the messages should now be in the DLQ
-
- MessageConsumer cons3 = sess.createConsumer(queue2);
-
+
+ // All the messages should now be in the DLQ
+
+ MessageConsumer cons3 = sess.createConsumer(queue2);
+
for (int i = 0; i < NUM_MESSAGES; i++)
{
TextMessage tm = (TextMessage)cons3.receive(1000);
-
+
assertNotNull(tm);
assertEquals("Message:" + i, tm.getText());
}
- //No more should be available
-
+ // No more should be available
+
checkEmpty(queue1);
}
finally
{
ServerManagement.undeployQueue("DLQ");
- if (conn != null) conn.close();
+ if (conn != null)
+ conn.close();
}
}
-
+
protected int getDefaultMaxDeliveryAttempts() throws Exception
{
- return ((Integer) ServerManagement.getAttribute(
- ServerManagement.getServerPeerObjectName(),
- "DefaultMaxDeliveryAttempts"))
- .intValue();
+ return ((Integer)ServerManagement.getAttribute(ServerManagement.getServerPeerObjectName(),
+ "DefaultMaxDeliveryAttempts")).intValue();
}
protected void setMaxDeliveryAttempts(ObjectName dest, int maxDeliveryAttempts) throws Exception
{
- ServerManagement.setAttribute(dest, "MaxDeliveryAttempts",
- Integer.toString(maxDeliveryAttempts));
+ ServerManagement.setAttribute(dest, "MaxDeliveryAttempts", Integer.toString(maxDeliveryAttempts));
}
-
+
protected void testMaxDeliveryAttempts(Destination destination, int destMaxDeliveryAttempts, boolean queue) throws Exception
{
Connection conn = cf.createConnection();
-
+
if (!queue)
{
- conn.setClientID("wib123");
+ conn.setClientID("wib123");
}
-
+
try
{
- ServerManagement.setAttribute(ServerManagement.getServerPeerObjectName(),
- "DefaultDLQ", "jboss.messaging.destination:service=Queue,name=Queue2");
-
+ ServerManagement.setAttribute(ServerManagement.getServerPeerObjectName(),
+ "DefaultDLQ",
+ "jboss.messaging.destination:service=Queue,name=Queue2");
+
// Create the consumer before the producer so that the message we send doesn't
// get lost if the destination is a Topic.
- Session consumingSession = conn.createSession(false, Session.CLIENT_ACKNOWLEDGE);
+ Session consumingSession = conn.createSession(false, Session.CLIENT_ACKNOWLEDGE);
MessageConsumer destinationConsumer;
-
+
if (queue)
{
destinationConsumer = consumingSession.createConsumer(destination);
}
else
{
- //For topics we only keep a delivery record on the server side for durable subs
- destinationConsumer = consumingSession.createDurableSubscriber((Topic)destination, "testsub1");
+ // For topics we only keep a delivery record on the server side for durable subs
+ destinationConsumer = consumingSession.createDurableSubscriber((Topic)destination, "testsub1");
}
-
+
{
Session producingSession = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer prod = producingSession.createProducer(destination);
@@ -827,7 +928,7 @@
// Make delivery attempts up to the maximum. The message should not end up in the DLQ.
for (int i = 0; i < destMaxDeliveryAttempts; i++)
- {
+ {
TextMessage tm = (TextMessage)destinationConsumer.receive(1000);
assertNotNull("No message received on delivery attempt number " + (i + 1), tm);
assertEquals("Message", tm.getText());
@@ -836,26 +937,26 @@
// At this point the message should not yet be in the DLQ
checkEmpty(queue2);
-
+
// Now we try to consume the message again from the destination, which causes it
// to go to the DLQ instead.
Message m = destinationConsumer.receive(100);
assertNull(m);
-
+
// The message should be in the DLQ now
MessageConsumer dlqConsumer = consumingSession.createConsumer(queue2);
m = dlqConsumer.receive(1000);
assertNotNull(m);
assertTrue(m instanceof TextMessage);
- assertEquals("Message", ((TextMessage) m).getText());
-
+ assertEquals("Message", ((TextMessage)m).getText());
+
m.acknowledge();
-
+
if (!queue)
{
- destinationConsumer.close();
-
- consumingSession.unsubscribe("testsub1");
+ destinationConsumer.close();
+
+ consumingSession.unsubscribe("testsub1");
}
}
finally
@@ -870,35 +971,35 @@
// Private -------------------------------------------------------
// Inner classes -------------------------------------------------
-
+
class FailingMessageListener implements MessageListener
{
volatile int deliveryCount;
-
+
int numMessages;
-
+
FailingMessageListener(int numMessages)
{
- this.numMessages = numMessages;
+ this.numMessages = numMessages;
}
-
+
synchronized void waitForMessages() throws Exception
{
- while (deliveryCount != numMessages)
+ while (deliveryCount != numMessages)
{
- this.wait();
+ this.wait();
}
}
-
+
public synchronized void onMessage(Message msg)
{
deliveryCount++;
-
+
this.notify();
-
+
throw new RuntimeException("Your mum!");
}
-
+
}
}
Modified: branches/Branch_1_4/tests/src/org/jboss/test/messaging/jms/ExpiryQueueTest.java
===================================================================
--- branches/Branch_1_4/tests/src/org/jboss/test/messaging/jms/ExpiryQueueTest.java 2008-09-24 23:08:48 UTC (rev 5023)
+++ branches/Branch_1_4/tests/src/org/jboss/test/messaging/jms/ExpiryQueueTest.java 2008-09-25 04:52:34 UTC (rev 5024)
@@ -1,23 +1,13 @@
/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ * JBoss, Home of Professional Open Source Copyright 2005, JBoss Inc., and individual contributors as indicated by the
+ * @authors tag. See the copyright.txt in the distribution for a full listing of individual contributors. This is free
+ * software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+ * This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details. You should have received a copy of the GNU Lesser General Public License along with this software; if not,
+ * write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
*/
package org.jboss.test.messaging.jms;
@@ -42,14 +32,10 @@
import org.jboss.test.messaging.tools.ServerManagement;
/**
+ * A ExpiryQueueTest
*
- * A ExpiryQueueTest
- *
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- *
+ * @version <tt>$Revision$</tt> $Id$
*/
public class ExpiryQueueTest extends JMSTestCase
{
@@ -74,33 +60,36 @@
{
return;
}
-
+
try
- {
+ {
ServerManagement.deployQueue("ExpiryQueue");
-
+
ObjectName serverPeerObjectName = ServerManagement.getServerPeerObjectName();
-
- ObjectName expiryQueueObjectName = (ObjectName)ServerManagement.getAttribute(serverPeerObjectName, "DefaultExpiryQueue");
-
+
+ ObjectName expiryQueueObjectName = (ObjectName)ServerManagement.getAttribute(serverPeerObjectName,
+ "DefaultExpiryQueue");
+
assertNotNull(expiryQueueObjectName);
-
+
String name = (String)ServerManagement.getAttribute(expiryQueueObjectName, "Name");
-
+
assertNotNull(name);
-
+
assertEquals("ExpiryQueue", name);
-
+
String jndiName = (String)ServerManagement.getAttribute(expiryQueueObjectName, "JNDIName");
-
+
assertNotNull(jndiName);
-
+
assertEquals("/queue/ExpiryQueue", jndiName);
-
- org.jboss.messaging.core.contract.Queue expiryQueue = ServerManagement.getServer().getServerPeer().getDefaultExpiryQueueInstance();
-
+
+ org.jboss.messaging.core.contract.Queue expiryQueue = ServerManagement.getServer()
+ .getServerPeer()
+ .getDefaultExpiryQueueInstance();
+
assertNotNull(expiryQueue);
-
+
JBossQueue q = (JBossQueue)ic.lookup("/queue/ExpiryQueue");
assertNotNull(q);
@@ -119,9 +108,11 @@
{
return;
}
-
- org.jboss.messaging.core.contract.Queue expiryQueue = ServerManagement.getServer().getServerPeer().getDefaultExpiryQueueInstance();
+ org.jboss.messaging.core.contract.Queue expiryQueue = ServerManagement.getServer()
+ .getServerPeer()
+ .getDefaultExpiryQueueInstance();
+
assertNull(expiryQueue);
try
@@ -132,281 +123,278 @@
}
catch (NameNotFoundException e)
{
- //Ok
+ // Ok
}
}
-
+
public void testDefaultAndOverrideExpiryQueue() throws Exception
{
final int NUM_MESSAGES = 5;
-
+
Connection conn = null;
-
+
ObjectName serverPeerObjectName = ServerManagement.getServerPeerObjectName();
-
+
try
- {
+ {
ServerManagement.deployQueue("DefaultExpiry");
-
+
ServerManagement.deployQueue("OverrideExpiry");
-
+
ServerManagement.deployQueue("TestQueue");
-
+
String defaultExpiryObjectName = "jboss.messaging.destination:service=Queue,name=DefaultExpiry";
-
+
String overrideExpiryObjectName = "jboss.messaging.destination:service=Queue,name=OverrideExpiry";
-
- String testQueueObjectName = "jboss.messaging.destination:service=Queue,name=TestQueue";
-
+
+ String testQueueObjectName = "jboss.messaging.destination:service=Queue,name=TestQueue";
+
ServerManagement.setAttribute(serverPeerObjectName, "DefaultExpiryQueue", defaultExpiryObjectName);
-
+
ServerManagement.setAttribute(new ObjectName(testQueueObjectName), "ExpiryQueue", "");
-
+
Queue testQueue = (Queue)ic.lookup("/queue/TestQueue");
-
+
Queue defaultExpiry = (Queue)ic.lookup("/queue/DefaultExpiry");
-
+
Queue overrideExpiry = (Queue)ic.lookup("/queue/OverrideExpiry");
-
+
conn = cf.createConnection();
-
- {
+
+ {
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
+
MessageProducer prod = sess.createProducer(testQueue);
-
+
conn.start();
-
+
for (int i = 0; i < NUM_MESSAGES; i++)
{
TextMessage tm = sess.createTextMessage("Message:" + i);
-
- //Send messages with time to live of 2000 enough time to get to client consumer - so
- //they won't be expired on the server side
+
+ // Send messages with time to live of 2000 enough time to get to client consumer - so
+ // they won't be expired on the server side
prod.send(tm, DeliveryMode.PERSISTENT, 4, 2000);
}
-
+
Session sess2 = conn.createSession(false, Session.CLIENT_ACKNOWLEDGE);
-
+
MessageConsumer cons = sess2.createConsumer(testQueue);
-
- //The messages should now be sitting in the consumer buffer
-
- //Now give them enough time to expire
-
+
+ // The messages should now be sitting in the consumer buffer
+
+ // Now give them enough time to expire
+
Thread.sleep(2500);
-
- //Now try and receive
-
+
+ // Now try and receive
+
Message m = cons.receive(1000);
assertNull(m);
- //Message should all be in the default expiry queue - let's check
-
+ // Message should all be in the default expiry queue - let's check
+
MessageConsumer cons3 = sess.createConsumer(defaultExpiry);
-
+
for (int i = 0; i < NUM_MESSAGES; i++)
{
TextMessage tm = (TextMessage)cons3.receive(1000);
-
+
assertNotNull(tm);
-
+
assertEquals("Message:" + i, tm.getText());
}
-
+
conn.close();
}
-
-
- //now try with overriding the default expiry queue
- {
+
+ // now try with overriding the default expiry queue
+ {
ServerManagement.setAttribute(new ObjectName(testQueueObjectName), "ExpiryQueue", overrideExpiryObjectName);
-
+
conn = cf.createConnection();
-
+
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
+
MessageProducer prod = sess.createProducer(testQueue);
-
+
conn.start();
-
+
for (int i = 0; i < NUM_MESSAGES; i++)
{
TextMessage tm = sess.createTextMessage("Message:" + i);
-
- //Send messages with time to live of 2000 enough time to get to client consumer - so
- //they won't be expired on the server side
+
+ // Send messages with time to live of 2000 enough time to get to client consumer - so
+ // they won't be expired on the server side
prod.send(tm, DeliveryMode.PERSISTENT, 4, 2000);
}
-
+
Session sess2 = conn.createSession(false, Session.CLIENT_ACKNOWLEDGE);
-
+
MessageConsumer cons = sess2.createConsumer(testQueue);
-
- //The messages should now be sitting in the consumer buffer
-
- //Now give them enough time to expire
-
+
+ // The messages should now be sitting in the consumer buffer
+
+ // Now give them enough time to expire
+
Thread.sleep(2500);
-
- //Now try and receive
-
+
+ // Now try and receive
+
Message m = cons.receive(1000);
assertNull(m);
- //Message should all be in the override expiry queue - let's check
-
+ // Message should all be in the override expiry queue - let's check
+
MessageConsumer cons3 = sess.createConsumer(overrideExpiry);
-
+
for (int i = 0; i < NUM_MESSAGES; i++)
{
TextMessage tm = (TextMessage)cons3.receive(1000);
-
+
assertNotNull(tm);
-
+
assertEquals("Message:" + i, tm.getText());
}
}
}
finally
{
- ServerManagement.setAttribute(serverPeerObjectName, "DefaultExpiryQueue", "jboss.messaging.destination:service=Queue,name=ExpiryQueue");
-
+ ServerManagement.setAttribute(serverPeerObjectName,
+ "DefaultExpiryQueue",
+ "jboss.messaging.destination:service=Queue,name=ExpiryQueue");
+
ServerManagement.undeployQueue("DefaultDLQ");
-
+
ServerManagement.undeployQueue("OverrideDLQ");
-
+
ServerManagement.undeployQueue("TestQueue");
-
+
if (conn != null)
{
conn.close();
}
}
}
-
+
public void testExpireSameMessagesMultiple() throws Exception
{
final int NUM_MESSAGES = 5;
-
+
Connection conn = null;
-
+
try
- {
+ {
ServerManagement.deployQueue("ExpiryQueue");
-
+
String defaultExpiryObjectName = "jboss.messaging.destination:service=Queue,name=ExpiryQueue";
-
+
ObjectName serverPeerObjectName = ServerManagement.getServerPeerObjectName();
-
+
ServerManagement.setAttribute(serverPeerObjectName, "DefaultExpiryQueue", defaultExpiryObjectName);
-
+
Queue defaultExpiry = (Queue)ic.lookup("/queue/ExpiryQueue");
-
+
conn = cf.createConnection();
-
+
conn.setClientID("wib1");
-
+
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
+
MessageProducer prod = sess.createProducer(topic1);
-
+
conn.start();
-
- //Create 3 durable subscriptions
-
+
+ // Create 3 durable subscriptions
+
MessageConsumer sub1 = sess.createDurableSubscriber(topic1, "sub1");
-
+
MessageConsumer sub2 = sess.createDurableSubscriber(topic1, "sub2");
-
+
MessageConsumer sub3 = sess.createDurableSubscriber(topic1, "sub3");
-
+
Map origIds = new HashMap();
-
+
long now = System.currentTimeMillis();
-
+
for (int i = 0; i < NUM_MESSAGES; i++)
{
TextMessage tm = sess.createTextMessage("Message:" + i);
- //Send messages with time to live of 3000 enough time to get to client consumer - so
- //they won't be expired on the server side
+ // Send messages with time to live of 3000 enough time to get to client consumer - so
+ // they won't be expired on the server side
prod.send(tm, DeliveryMode.PERSISTENT, 4, 3000);
-
+
origIds.put(tm.getText(), tm.getJMSMessageID());
}
-
+
long approxExpiry = now + 3000;
-
-
- //Now sleep. This wil give them enough time to expire
-
+
+ // Now sleep. This wil give them enough time to expire
+
Thread.sleep(3500);
-
- //Now try and consume from each - this should force the message to the expiry queue
-
+
+ // Now try and consume from each - this should force the message to the expiry queue
+
Message m = sub1.receive(500);
assertNull(m);
-
+
m = sub2.receive(500);
assertNull(m);
-
+
m = sub3.receive(500);
assertNull(m);
-
- //Now the messages should all be in the expiry queue
-
+
+ // Now the messages should all be in the expiry queue
+
MessageConsumer cons2 = sess.createConsumer(defaultExpiry);
-
+
while (true)
{
TextMessage tm = (TextMessage)cons2.receive(500);
-
+
if (tm == null)
{
break;
}
-
+
// Check the headers
- String origDest =
- tm.getStringProperty(JBossMessage.JBOSS_MESSAGING_ORIG_DESTINATION);
-
- String origMessageId =
- tm.getStringProperty(JBossMessage.JBOSS_MESSAGING_ORIG_MESSAGE_ID);
-
- long actualExpiryTime =
- tm.getLongProperty(JBossMessage.JBOSS_MESSAGING_ACTUAL_EXPIRY_TIME);
-
+ String origDest = tm.getStringProperty(JBossMessage.JBOSS_MESSAGING_ORIG_DESTINATION);
+
+ String origMessageId = tm.getStringProperty(JBossMessage.JBOSS_MESSAGING_ORIG_MESSAGE_ID);
+
+ long actualExpiryTime = tm.getLongProperty(JBossMessage.JBOSS_MESSAGING_ACTUAL_EXPIRY_TIME);
+
assertEquals(topic1.toString(), origDest);
-
+
String origId = (String)origIds.get(tm.getText());
-
+
assertEquals(origId, origMessageId);
-
+
assertTrue(actualExpiryTime >= approxExpiry);
}
-
+
cons2.close();
-
+
sub1.close();
-
+
sub2.close();
-
+
sub3.close();
-
+
sess.unsubscribe("sub1");
-
+
sess.unsubscribe("sub2");
-
+
sess.unsubscribe("sub3");
-
+
}
finally
- {
+ {
ServerManagement.undeployQueue("ExpiryQueue");
-
+
if (conn != null)
{
conn.close();
@@ -432,22 +420,22 @@
public void testWithReceiveNonPersistent() throws Exception
{
testWithReceive(false);
- }
+ }
public void testWithMessageListener(boolean persistent) throws Exception
- {
+ {
Connection conn = null;
-
+
try
{
ServerManagement.deployQueue("ExpiryQueue");
-
+
Queue expiryQueue = (Queue)ic.lookup("/queue/ExpiryQueue");
-
+
final int NUM_MESSAGES = 5;
conn = cf.createConnection();
-
+
conn.start();
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
@@ -455,51 +443,51 @@
MessageProducer prod = sess.createProducer(queue1);
int deliveryMode = persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT;
-
+
for (int i = 0; i < NUM_MESSAGES; i++)
{
TextMessage tm = sess.createTextMessage("Message:" + i);
-
- //Send messages with time to live of 2000 enough time to get to client consumer - so
- //they won't be expired on the server side
+
+ // Send messages with time to live of 2000 enough time to get to client consumer - so
+ // they won't be expired on the server side
prod.send(tm, deliveryMode, 4, 2000);
}
MessageConsumer cons = sess.createConsumer(queue1);
-
- //The messages should now be sitting in the consumer buffer
-
- //Now give them enough time to expire
-
+
+ // The messages should now be sitting in the consumer buffer
+
+ // Now give them enough time to expire
+
Thread.sleep(2500);
-
- //Now set a listener
-
- FailingMessageListener listener = new FailingMessageListener();
+ // Now set a listener
+
+ FailingMessageListener listener = new FailingMessageListener();
+
cons.setMessageListener(listener);
-
+
Thread.sleep(1000);
cons.setMessageListener(null);
-
- //No messages should have been received
+
+ // No messages should have been received
assertEquals(0, listener.deliveryCount);
-
- //Shouldn't be able to receive any more
-
+
+ // Shouldn't be able to receive any more
+
Message m = cons.receive(1000);
assertNull(m);
- //Message should all be in the expiry queue - let's check
-
+ // Message should all be in the expiry queue - let's check
+
MessageConsumer cons2 = sess.createConsumer(expiryQueue);
-
+
for (int i = 0; i < NUM_MESSAGES; i++)
{
TextMessage tm = (TextMessage)cons2.receive(1000);
-
+
assertNotNull(tm);
assertEquals("Message:" + i, tm.getText());
@@ -510,25 +498,26 @@
{
ServerManagement.undeployQueue("ExpiryQueue");
- if (conn != null) conn.close();
+ if (conn != null)
+ conn.close();
}
}
-
+
public void testWithReceive(boolean persistent) throws Exception
{
Connection conn = null;
-
+
try
{
ServerManagement.deployQueue("ExpiryQueue");
-
+
Queue expiryQueue = (Queue)ic.lookup("/queue/ExpiryQueue");
-
+
final int NUM_MESSAGES = 5;
conn = cf.createConnection();
-
+
conn.start();
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
@@ -536,38 +525,38 @@
MessageProducer prod = sess.createProducer(queue1);
int deliveryMode = persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT;
-
+
for (int i = 0; i < NUM_MESSAGES; i++)
{
TextMessage tm = sess.createTextMessage("Message:" + i);
-
- //Send messages with time to live of 2000 enough time to get to client consumer - so
- //they won't be expired on the server side
+
+ // Send messages with time to live of 2000 enough time to get to client consumer - so
+ // they won't be expired on the server side
prod.send(tm, deliveryMode, 4, 2000);
}
MessageConsumer cons = sess.createConsumer(queue1);
-
- //The messages should now be sitting in the consumer buffer
-
- //Now give them enough time to expire
-
+
+ // The messages should now be sitting in the consumer buffer
+
+ // Now give them enough time to expire
+
Thread.sleep(2500);
-
- //Now try and receive
-
+
+ // Now try and receive
+
Message m = cons.receive(1000);
assertNull(m);
- //Message should all be in the expiry queue - let's check
-
+ // Message should all be in the expiry queue - let's check
+
MessageConsumer cons2 = sess.createConsumer(expiryQueue);
-
+
for (int i = 0; i < NUM_MESSAGES; i++)
{
TextMessage tm = (TextMessage)cons2.receive(1000);
-
+
assertNotNull(tm);
assertEquals("Message:" + i, tm.getText());
@@ -578,24 +567,28 @@
{
ServerManagement.undeployQueue("ExpiryQueue");
- if (conn != null) conn.close();
+ if (conn != null)
+ conn.close();
}
}
-
+
public void testExpirationTransfer() throws Exception
{
ServerManagement.deployQueue("ExpiryQueue");
- Object originalValue = ServerManagement.getAttribute(ServerManagement.getServerPeerObjectName(), "DefaultExpiryQueue");
+ Object originalValue = ServerManagement.getAttribute(ServerManagement.getServerPeerObjectName(),
+ "DefaultExpiryQueue");
- ServerManagement.setAttribute(ServerManagement.getServerPeerObjectName(), "DefaultExpiryQueue", "jboss.messaging.destination:service=Queue,name=ExpiryQueue");
+ ServerManagement.setAttribute(ServerManagement.getServerPeerObjectName(),
+ "DefaultExpiryQueue",
+ "jboss.messaging.destination:service=Queue,name=ExpiryQueue");
Connection conn = null;
try
{
ConnectionFactory cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
-
+
conn = cf.createConnection();
Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
@@ -615,12 +608,12 @@
MessageConsumer cons = session.createConsumer(queue1);
assertNull(cons.receive(3000));
-
+
Queue queueExpiryQueue = (Queue)ic.lookup("/queue/ExpiryQueue");
MessageConsumer consumerExpiredQueue = session.createConsumer(queueExpiryQueue);
- TextMessage txt = (TextMessage) consumerExpiredQueue.receive(1000);
+ TextMessage txt = (TextMessage)consumerExpiredQueue.receive(1000);
assertEquals("This message will die", txt.getText());
@@ -632,14 +625,113 @@
{
conn.close();
}
-
+
ServerManagement.destroyQueue("ExpiryQueue");
-
- ServerManagement.setAttribute(ServerManagement.getServerPeerObjectName(), "DefaultExpiryQueue", originalValue.toString());
+
+ ServerManagement.setAttribute(ServerManagement.getServerPeerObjectName(),
+ "DefaultExpiryQueue",
+ originalValue.toString());
}
}
-
+ // https://jira.jboss.org/jira/browse/JBMESSAGING-1374
+ public void testForwardReferencedExpiryQueue() throws Exception
+ {
+ if (ServerManagement.isRemote())
+ {
+ return;
+ }
+
+ final int NUM_MESSAGES = 5;
+ ObjectName serverPeerObjectName = ServerManagement.getServerPeerObjectName();
+
+ String testQueueName = "testQueue";
+ String testTopicName = "testTopic";
+
+ String testDLQName = "testDLQ";
+ String testExpiryQName = "testExpiryQ";
+
+ Connection conn = null;
+
+ try
+ {
+ ServerManagement.deployQueue("DLQ");
+ ServerManagement.deployQueue("ExpiryQueue");
+
+ ObjectName myQueue = ServerManagement.deployQueueWithDLQnExpiryQ(testQueueName, testDLQName, testExpiryQName);
+ ObjectName myTopic = ServerManagement.deployTopicWithDLQnExpiryQ(testTopicName, testDLQName, testExpiryQName);
+ ObjectName myDLQ = ServerManagement.deployQueueWithoutStart(testDLQName);
+ ObjectName myExpiryQueue = ServerManagement.deployQueueWithoutStart(testExpiryQName);
+
+ assertNotNull(myQueue);
+ assertNotNull(myTopic);
+ assertNotNull(myDLQ);
+ assertNotNull(myExpiryQueue);
+
+ ServerManagement.startDestinationService(new ObjectName[] { myQueue, myTopic, myDLQ, myExpiryQueue });
+
+ conn = cf.createConnection();
+
+ {
+ Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ Queue myTestQRef = (Queue)ic.lookup("/queue/testQueue");
+ Queue myExpQRef = (Queue)ic.lookup("/queue/testExpiryQ");
+ MessageProducer prod = sess.createProducer(myTestQRef);
+
+ conn.start();
+
+ for (int i = 0; i < NUM_MESSAGES; i++)
+ {
+ TextMessage tm = sess.createTextMessage("Message:" + i);
+
+ // Send messages with time to live of 2000 enough time to get to client consumer - so
+ // they won't be expired on the server side
+ prod.send(tm, DeliveryMode.PERSISTENT, 4, 2000);
+ }
+
+ Session sess2 = conn.createSession(false, Session.CLIENT_ACKNOWLEDGE);
+
+ MessageConsumer cons = sess2.createConsumer(myTestQRef);
+
+ // The messages should now be sitting in the consumer buffer
+
+ // Now give them enough time to expire
+
+ Thread.sleep(2500);
+
+ // Now try and receive
+
+ Message m = cons.receive(1000);
+
+ assertNull(m);
+
+ // Message should all be in the default expiry queue - let's check
+
+ MessageConsumer cons3 = sess.createConsumer(myExpQRef);
+
+ for (int i = 0; i < NUM_MESSAGES; i++)
+ {
+ TextMessage tm = (TextMessage)cons3.receive(1000);
+
+ assertNotNull(tm);
+
+ assertEquals("Message:" + i, tm.getText());
+ }
+
+ conn.close();
+ }
+ }
+ finally
+ {
+
+ if (conn != null)
+ {
+ conn.close();
+ }
+ }
+ }
+
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
@@ -647,7 +739,7 @@
// Private -------------------------------------------------------
// Inner classes -------------------------------------------------
-
+
class FailingMessageListener implements MessageListener
{
volatile int deliveryCount;
@@ -655,10 +747,10 @@
public void onMessage(Message msg)
{
deliveryCount++;
-
+
throw new RuntimeException("Your mum!");
}
-
+
}
}
Modified: branches/Branch_1_4/tests/src/org/jboss/test/messaging/tools/ServerManagement.java
===================================================================
--- branches/Branch_1_4/tests/src/org/jboss/test/messaging/tools/ServerManagement.java 2008-09-24 23:08:48 UTC (rev 5023)
+++ branches/Branch_1_4/tests/src/org/jboss/test/messaging/tools/ServerManagement.java 2008-09-25 04:52:34 UTC (rev 5024)
@@ -1,24 +1,14 @@
/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
+ * JBoss, Home of Professional Open Source Copyright 2005, JBoss Inc., and individual contributors as indicated by the
+ * @authors tag. See the copyright.txt in the distribution for a full listing of individual contributors. This is free
+ * software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+ * This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details. You should have received a copy of the GNU Lesser General Public License along with this software; if not,
+ * write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
+ */
package org.jboss.test.messaging.tools;
import java.io.BufferedReader;
@@ -52,30 +42,34 @@
import org.jboss.test.messaging.tools.container.ServiceAttributeOverrides;
/**
- * Collection of static methods to use to start/stop and interact with the in-memory JMS server. It
- * is also use to start/stop a remote server.
- *
+ * Collection of static methods to use to start/stop and interact with the in-memory JMS server. It is also use to
+ * start/stop a remote server.
+ *
* @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
+ * @version <tt>$Revision$</tt> $Id$
*/
public class ServerManagement
{
// Constants -----------------------------------------------------
-
+
public static final int MAX_SERVER_COUNT = 10;
// logging levels used by the remote client to forward log output on a remote server
public static int FATAL = 0;
+
public static int ERROR = 1;
+
public static int WARN = 2;
+
public static int INFO = 3;
+
public static int DEBUG = 4;
+
public static int TRACE = 5;
public static final String DEFAULT_QUEUE_CONTEXT = "/queue";
+
public static final String DEFAULT_TOPIC_CONTEXT = "/topic";
// Static --------------------------------------------------------
@@ -96,7 +90,7 @@
}
}
};
-
+
// A hook to shutdown any spawned server
// This was done because of http://jira.jboss.com/jira/browse/JBMESSAGING-1395
static
@@ -153,35 +147,34 @@
}
/**
- * Makes sure that a "hollow" TestServer (either local or remote, depending on the nature of the
- * test), exists and it's ready to be started.
+ * Makes sure that a "hollow" TestServer (either local or remote, depending on the nature of the test), exists and
+ * it's ready to be started.
*/
public static synchronized Server create(int i) throws Exception
{
- log.info("Attempting to create server " + i);
+ log.info("Attempting to create server " + i);
if (servers[i] == null)
{
- log.info("Server not already created, so creating...");
+ log.info("Server not already created, so creating...");
if (isLocal())
{
servers[i] = new ServerHolder(new LocalTestServer(i), false);
}
else
{
- //Need to spawn a new server - we DON'T use start-rmi-server any more, so we know if the servers[i] is null
- //the server is not there - killing a server sets servers[i] to null
- servers[i] = new ServerHolder(ServerManagement.spawn(i), true);
+ // Need to spawn a new server - we DON'T use start-rmi-server any more, so we know if the servers[i] is null
+ // the server is not there - killing a server sets servers[i] to null
+ servers[i] = new ServerHolder(ServerManagement.spawn(i), true);
}
}
else
{
- log.info("Server already created, so skipping");
+ log.info("Server already created, so skipping");
}
return servers[i].getServer();
}
-
/**
* Will clear the database at startup.
*/
@@ -203,24 +196,23 @@
start(i, config, null, clearDatabase);
}
- public static void start(int i, String config,
- ServiceAttributeOverrides attrOverrides,
- boolean clearDatabase) throws Exception
+ public static void start(int i, String config, ServiceAttributeOverrides attrOverrides, boolean clearDatabase) throws Exception
{
start(i, config, attrOverrides, clearDatabase, true);
}
/**
- * When this method correctly completes, the server (local or remote) is started and fully
- * operational (the service container and the server peer are created and started).
+ * When this method correctly completes, the server (local or remote) is started and fully operational (the service
+ * container and the server peer are created and started).
*/
- public static void start(int i, String config,
- ServiceAttributeOverrides attrOverrides,
- boolean clearDatabase,
- boolean startMessagingServer) throws Exception
+ public static void start(int i,
+ String config,
+ ServiceAttributeOverrides attrOverrides,
+ boolean clearDatabase,
+ boolean startMessagingServer) throws Exception
{
log.info("Attempting to start server " + i);
-
+
Server s = create(i);
s.start(config, attrOverrides, clearDatabase, startMessagingServer);
@@ -228,7 +220,6 @@
log.info("server " + i + " started");
}
-
public static synchronized boolean isStarted(int i) throws Exception
{
if (servers[i] == null)
@@ -237,7 +228,7 @@
}
else
{
- return servers[i].getServer().isStarted();
+ return servers[i].getServer().isStarted();
}
}
@@ -247,10 +238,11 @@
}
/**
- * The method stops the local or remote server, bringing it to a "hollow" state. A stopped
- * server is identical with a server that has just been created, but not started.
- * @return true if the server was effectively stopped, or false if the server was alreayd stopped
- * when the method was invoked.
+ * The method stops the local or remote server, bringing it to a "hollow" state. A stopped server is identical with a
+ * server that has just been created, but not started.
+ *
+ * @return true if the server was effectively stopped, or false if the server was alreayd stopped when the method was
+ * invoked.
*/
public static boolean stop(int i) throws Exception
{
@@ -269,25 +261,25 @@
return stopped;
}
}
-
+
public static synchronized void kill(int i) throws Exception
{
- log.info("Attempting to kill server " + i);
-
- ServerHolder holder = servers[i];
-
- if (i == 0)
- {
- //Cannot kill server 0 if there are any other servers since it has the rmi registry in it
- for (int j = 1; j < servers.length; j++)
- {
- if (servers[j] != null)
- {
- throw new IllegalStateException("Cannot kill server 0, since server[" + j + "] still exists");
- }
- }
- }
+ log.info("Attempting to kill server " + i);
+ ServerHolder holder = servers[i];
+
+ if (i == 0)
+ {
+ // Cannot kill server 0 if there are any other servers since it has the rmi registry in it
+ for (int j = 1; j < servers.length; j++)
+ {
+ if (servers[j] != null)
+ {
+ throw new IllegalStateException("Cannot kill server 0, since server[" + j + "] still exists");
+ }
+ }
+ }
+
if (holder == null)
{
log.info("server " + i + " has not been created or has already been killed, so it cannot be killed");
@@ -298,19 +290,19 @@
log.info("invoking kill() on server " + i);
try
{
- server.kill();
+ server.kill();
}
catch (Throwable t)
{
- // This is likely to throw an exception since the server dies before the response is received
- }
+ // This is likely to throw an exception since the server dies before the response is received
+ }
servers[i] = null;
-
+
log.info("Waiting for server to die");
-
+
try
{
- while(true)
+ while (true)
{
server.ping();
log.debug("server " + i + " still alive ...");
@@ -319,48 +311,44 @@
}
catch (Throwable e)
{
- //Ok
+ // Ok
}
-
+
Thread.sleep(300);
log.info("server " + i + " killed and dead");
}
-
+
}
-
+
/**
- * This method make sure that all servers that have been implicitely spawned when as a side
- * effect of create() and/or start() are killed. The method is important because a forked
- * ant junit task won't exit if processes created by it are still active. If you run tests
- * from ant, always call killSpawnedServers() in tearDown().
- *
- * The servers created directed invoking spawn() are not subject to destroySpawnedServers(); they
- * need to be explicitely killed.
- *
+ * This method make sure that all servers that have been implicitely spawned when as a side effect of create() and/or
+ * start() are killed. The method is important because a forked ant junit task won't exit if processes created by it
+ * are still active. If you run tests from ant, always call killSpawnedServers() in tearDown(). The servers created
+ * directed invoking spawn() are not subject to destroySpawnedServers(); they need to be explicitely killed.
+ *
* @return a List<Integer> containing the indexes of the destroyed servers.
- *
*/
public static synchronized List destroySpawnedServers() throws Exception
{
- log.info("################# Destroying spawned servers****");
+ log.info("################# Destroying spawned servers****");
List destroyed = new ArrayList();
- for(int i = 0; i < servers.length; i++)
+ for (int i = 0; i < servers.length; i++)
{
if (servers[i] != null && servers[i].isSpawned())
{
Server s = servers[i].getServer();
destroyed.add(new Integer(s.getServerID()));
-
+
log.info("Killing spawned server " + i);
try
{
- s.kill();
+ s.kill();
}
catch (Throwable t)
- {
+ {
}
servers[i] = null;
}
@@ -371,7 +359,6 @@
/**
* For a local test, is a noop, but for a remote test, the method call spawns a new VM
- *
*/
private static synchronized Server spawn(final int i) throws Exception
{
@@ -396,12 +383,11 @@
log.info("************************************************************************************************************************");
log.info("Starting server " + index + " with debug on port 1200" + remoteDebugIndex);
log.info("************************************************************************************************************************");
- sb.append("-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=1200").
- append(remoteDebugIndex);
+ sb.append("-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=1200")
+ .append(remoteDebugIndex);
}
}
-
String objectStoreDir = System.getProperty("objectstore.dir");
if (objectStoreDir != null)
@@ -416,22 +402,21 @@
}
sb.append("-Dmodule.output=").append(moduleOutput).append(' ');
-
+
String bindAddress = System.getProperty("test.bind.address");
if (bindAddress == null)
{
- bindAddress = "localhost";
+ bindAddress = "localhost";
}
sb.append("-Dtest.bind.address=").append(bindAddress).append(' ');
- //Use test.bind.address for the jgroups.bind_addr
-
+ // Use test.bind.address for the jgroups.bind_addr
+
String jgroupsBindAddr = bindAddress;
-
- sb.append("-D").append(org.jgroups.Global.BIND_ADDR).append("=")
- .append(jgroupsBindAddr).append(' ');
+ sb.append("-D").append(org.jgroups.Global.BIND_ADDR).append("=").append(jgroupsBindAddr).append(' ');
+
String database = System.getProperty("test.database");
if (database != null)
{
@@ -461,49 +446,49 @@
{
sb.append("-Dtest.remoting=").append(remoting).append(' ');
}
-
+
String groupName = System.getProperty("jboss.messaging.groupname");
log.info("******* GROUP NAME IS " + groupName);
if (groupName != null)
{
sb.append("-Djboss.messaging.groupname=").append(groupName).append(' ');
}
-
+
String dataChannelUDPPort = System.getProperty("jboss.messaging.datachanneludpport");
log.info("*** data UDP port is " + dataChannelUDPPort);
if (dataChannelUDPPort != null)
{
sb.append("-Djboss.messaging.datachanneludpport=").append(dataChannelUDPPort).append(' ');
}
-
+
String controlChannelUDPPort = System.getProperty("jboss.messaging.controlchanneludpport");
log.info("*** control UDP port is " + controlChannelUDPPort);
if (controlChannelUDPPort != null)
{
sb.append("-Djboss.messaging.controlchanneludpport=").append(controlChannelUDPPort).append(' ');
}
-
+
String dataChannelUDPAddress = System.getProperty("jboss.messaging.datachanneludpaddress");
log.info("*** data UDP address is " + dataChannelUDPAddress);
if (dataChannelUDPAddress != null)
{
sb.append("-Djboss.messaging.datachanneludpaddress=").append(dataChannelUDPAddress).append(' ');
}
-
+
String controlChannelUDPAddress = System.getProperty("jboss.messaging.controlchanneludpaddress");
log.info("*** control UDP address is " + controlChannelUDPAddress);
if (controlChannelUDPAddress != null)
{
sb.append("-Djboss.messaging.controlchanneludpaddress=").append(controlChannelUDPAddress).append(' ');
}
-
+
String ipttl = System.getProperty("jboss.messaging.ipttl");
log.info("*** ip_ttl is " + ipttl);
if (ipttl != null)
{
sb.append("-Djboss.messaging.ipttl=").append(ipttl).append(' ');
}
-
+
String testLogfileSuffix = System.getProperty("test.logfile.suffix");
if (testLogfileSuffix == null)
@@ -544,7 +529,7 @@
}
sb.append("org.jboss.test.messaging.tools.container.RMITestServer");
-
+
String commandLine = sb.toString();
Process process = Runtime.getRuntime().exec(commandLine);
@@ -554,7 +539,7 @@
// if you ever need to debug the spawing process, turn this flag to true:
String parameterVerbose = System.getProperty("test.spawn.verbose");
- final boolean verbose = parameterVerbose!=null && parameterVerbose.equals("true");
+ final boolean verbose = parameterVerbose != null && parameterVerbose.equals("true");
final BufferedReader rs = new BufferedReader(new InputStreamReader(process.getInputStream()));
final BufferedReader re = new BufferedReader(new InputStreamReader(process.getErrorStream()));
@@ -567,7 +552,7 @@
{
String line;
- while((line = rs.readLine()) != null)
+ while ((line = rs.readLine()) != null)
{
if (verbose)
{
@@ -575,7 +560,7 @@
}
}
}
- catch(Exception e)
+ catch (Exception e)
{
log.error("exception", e);
}
@@ -591,7 +576,7 @@
{
String line;
- while((line = re.readLine()) != null)
+ while ((line = re.readLine()) != null)
{
if (verbose)
{
@@ -599,7 +584,7 @@
}
}
}
- catch(Exception e)
+ catch (Exception e)
{
log.error("exception", e);
}
@@ -607,26 +592,25 @@
}, "Server " + i + " STDERR reader thread").start();
-
// put the invoking thread on wait until the server is actually up and running and bound
// in the RMI registry
log.info("spawned server " + i + ", waiting for it to come online");
Server s = acquireRemote(500, i, true);
-
+
log.info("Server contacted");
if (s == null)
{
log.error("Cannot contact newly spawned server " + i + ", most likely the attempt failed, timing out ...");
- throw new Exception("Cannot contact newly spawned server " + i + ", most likely the attempt failed, timing out ...");
+ throw new Exception("Cannot contact newly spawned server " + i +
+ ", most likely the attempt failed, timing out ...");
}
return s;
}
-
public static ObjectName deploy(String mbeanConfiguration) throws Exception
{
insureStarted();
@@ -644,30 +628,25 @@
return getAttribute(0, on, attribute);
}
- public static Object getAttribute(int serverIndex, ObjectName on, String attribute)
- throws Exception
+ public static Object getAttribute(int serverIndex, ObjectName on, String attribute) throws Exception
{
insureStarted(serverIndex);
return servers[serverIndex].getServer().getAttribute(on, attribute);
}
-
- public static void setAttribute(ObjectName on, String name, String valueAsString)
- throws Exception
+ public static void setAttribute(ObjectName on, String name, String valueAsString) throws Exception
{
insureStarted();
servers[0].getServer().setAttribute(on, name, valueAsString);
}
- public static Object invoke(ObjectName on, String operationName,
- Object[] params, String[] signature) throws Exception
+ public static Object invoke(ObjectName on, String operationName, Object[] params, String[] signature) throws Exception
{
insureStarted();
return servers[0].getServer().invoke(on, operationName, params, signature);
}
- public static void addNotificationListener(int serverIndex, ObjectName on,
- NotificationListener listener) throws Exception
+ public static void addNotificationListener(int serverIndex, ObjectName on, NotificationListener listener) throws Exception
{
insureStarted(serverIndex);
@@ -679,11 +658,11 @@
else
{
// is remote, need to poll
- NotificationListenerPoller p =
- new NotificationListenerPoller(((ServerHolder)servers[serverIndex]).getServer(),
- on, listener);
+ NotificationListenerPoller p = new NotificationListenerPoller(((ServerHolder)servers[serverIndex]).getServer(),
+ on,
+ listener);
- synchronized(notificationListenerPollers)
+ synchronized (notificationListenerPollers)
{
notificationListenerPollers.put(listener, p);
}
@@ -692,8 +671,7 @@
}
}
- public static void removeNotificationListener(int serverIndex, ObjectName on,
- NotificationListener listener) throws Exception
+ public static void removeNotificationListener(int serverIndex, ObjectName on, NotificationListener listener) throws Exception
{
insureStarted(serverIndex);
@@ -707,7 +685,7 @@
// is remote
NotificationListenerPoller p = null;
- synchronized(notificationListenerPollers)
+ synchronized (notificationListenerPollers)
{
p = (NotificationListenerPoller)notificationListenerPollers.remove(listener);
}
@@ -721,25 +699,25 @@
}
/**
- * Install dynamically an AOP advice that will do "bad things" on the server, simulating all
- * sorts of failures. I expect the name of this method to be refactored as we learn more about
- * this type of testing.
- * @return a reference to the server that has been poisoned. Use this reference to kill the
- * server after use.
+ * Install dynamically an AOP advice that will do "bad things" on the server, simulating all sorts of failures. I
+ * expect the name of this method to be refactored as we learn more about this type of testing.
+ *
+ * @return a reference to the server that has been poisoned. Use this reference to kill the server after use.
*/
public static Server poisonTheServer(int serverIndex, int type) throws Exception
{
insureStarted(serverIndex);
Server poisoned = servers[serverIndex].getServer();
- //We set the server to null so it can be recreated again, but ONLY for those poisons that cause the server to get killed
- //We do not do this for other poisons that don't
-
+ // We set the server to null so it can be recreated again, but ONLY for those poisons that cause the server to get
+ // killed
+ // We do not do this for other poisons that don't
+
if (type != PoisonInterceptor.LONG_SEND && type != PoisonInterceptor.NULL)
{
- servers[serverIndex] = null;
+ servers[serverIndex] = null;
}
-
+
poisoned.poisonTheServer(type);
return poisoned;
@@ -768,7 +746,8 @@
{
if (servers[index] == null)
{
- log.debug("The remote server " + index + " has not been created yet " +
+ log.debug("The remote server " + index +
+ " has not been created yet " +
"so this log won't make it to the server!");
return;
}
@@ -777,7 +756,7 @@
{
servers[index].getServer().log(level, text);
}
- catch(Exception e)
+ catch (Exception e)
{
log.error("failed to forward the logging request to the remote server", e);
}
@@ -794,9 +773,7 @@
* @param defaultQueueJNDIContext - if null, the jboss-service.xml value will be used.
* @param defaultTopicJNDIContext - if null, the jboss-service.xml value will be used.
*/
- public static void startServerPeer(int serverPeerID,
- String defaultQueueJNDIContext,
- String defaultTopicJNDIContext) throws Exception
+ public static void startServerPeer(int serverPeerID, String defaultQueueJNDIContext, String defaultTopicJNDIContext) throws Exception
{
startServerPeer(serverPeerID, defaultQueueJNDIContext, defaultTopicJNDIContext, null);
}
@@ -812,8 +789,11 @@
ServiceAttributeOverrides attrOverrids) throws Exception
{
insureStarted();
- servers[0].getServer().startServerPeer(serverPeerID, defaultQueueJNDIContext,
- defaultTopicJNDIContext, attrOverrids, false);
+ servers[0].getServer().startServerPeer(serverPeerID,
+ defaultQueueJNDIContext,
+ defaultTopicJNDIContext,
+ attrOverrids,
+ false);
}
public static void stopServerPeer() throws Exception
@@ -835,8 +815,8 @@
}
/**
- * @return a Set<String> with the subsystems currently registered with the Connector.
- * This method is supposed to work locally as well as remotely.
+ * @return a Set<String> with the subsystems currently registered with the Connector. This method is supposed to work
+ * locally as well as remotely.
*/
public static Set getConnectorSubsystems() throws Exception
{
@@ -845,22 +825,20 @@
}
/**
- * Add a ServerInvocationHandler to the remoting Connector. This method is supposed to work
- * locally as well as remotely.
+ * Add a ServerInvocationHandler to the remoting Connector. This method is supposed to work locally as well as
+ * remotely.
*/
- public static void addServerInvocationHandler(String subsystem,
- ServerInvocationHandler handler) throws Exception
+ public static void addServerInvocationHandler(String subsystem, ServerInvocationHandler handler) throws Exception
{
insureStarted();
servers[0].getServer().addServerInvocationHandler(subsystem, handler);
}
/**
- * Remove a ServerInvocationHandler from the remoting Connector. This method is supposed to work
- * locally as well as remotely.
+ * Remove a ServerInvocationHandler from the remoting Connector. This method is supposed to work locally as well as
+ * remotely.
*/
- public static void removeServerInvocationHandler(String subsystem)
- throws Exception
+ public static void removeServerInvocationHandler(String subsystem) throws Exception
{
insureStarted();
servers[0].getServer().removeServerInvocationHandler(subsystem);
@@ -872,28 +850,24 @@
return servers[0].getServer().getMessageStore();
}
- public static DestinationManager getDestinationManager()
- throws Exception
+ public static DestinationManager getDestinationManager() throws Exception
{
insureStarted();
return servers[0].getServer().getDestinationManager();
}
- public static PersistenceManager getPersistenceManager()
- throws Exception
+ public static PersistenceManager getPersistenceManager() throws Exception
{
insureStarted();
return servers[0].getServer().getPersistenceManager();
}
- public static void configureSecurityForDestination(String destName, String config)
- throws Exception
+ public static void configureSecurityForDestination(String destName, String config) throws Exception
{
configureSecurityForDestination(0, destName, config);
}
- public static void configureSecurityForDestination(int serverID, String destName, String config)
- throws Exception
+ public static void configureSecurityForDestination(int serverID, String destName, String config) throws Exception
{
insureStarted(serverID);
servers[serverID].getServer().configureSecurityForDestination(destName, config);
@@ -940,8 +914,7 @@
/**
* Simulates a topic deployment (copying the topic descriptor in the deploy directory).
*/
- public static void deployTopic(String name, int fullSize, int pageSize, int downCacheSize)
- throws Exception
+ public static void deployTopic(String name, int fullSize, int pageSize, int downCacheSize) throws Exception
{
deployTopic(name, null, fullSize, pageSize, downCacheSize);
}
@@ -949,19 +922,23 @@
/**
* Simulates a topic deployment (copying the topic descriptor in the deploy directory).
*/
- public static void deployTopic(String name, String jndiName, int fullSize, int pageSize,
- int downCacheSize) throws Exception
+ public static void deployTopic(String name, String jndiName, int fullSize, int pageSize, int downCacheSize) throws Exception
{
insureStarted();
servers[0].getServer().deployTopic(name, jndiName, fullSize, pageSize, downCacheSize, false);
}
-
- public static void deployTopic(String name, String jndiName, int fullSize, int pageSize,
- int downCacheSize, int serverIndex, boolean clustered) throws Exception
+
+ public static void deployTopic(String name,
+ String jndiName,
+ int fullSize,
+ int pageSize,
+ int downCacheSize,
+ int serverIndex,
+ boolean clustered) throws Exception
{
- insureStarted();
- servers[serverIndex].getServer().deployTopic(name, jndiName, fullSize, pageSize, downCacheSize, clustered);
- }
+ insureStarted();
+ servers[serverIndex].getServer().deployTopic(name, jndiName, fullSize, pageSize, downCacheSize, clustered);
+ }
/**
* Simulates a topic un-deployment (deleting the topic descriptor from the deploy directory).
@@ -1025,8 +1002,7 @@
/**
* Simulates a queue deployment (copying the queue descriptor in the deploy directory).
*/
- public static void deployQueue(String name, int fullSize, int pageSize, int downCacheSize)
- throws Exception
+ public static void deployQueue(String name, int fullSize, int pageSize, int downCacheSize) throws Exception
{
deployQueue(name, null, fullSize, pageSize, downCacheSize);
}
@@ -1034,26 +1010,67 @@
/**
* Simulates a queue deployment (copying the queue descriptor in the deploy directory).
*/
- public static void deployQueue(String name, String jndiName, int fullSize, int pageSize,
- int downCacheSize) throws Exception
+ public static void deployQueue(String name, String jndiName, int fullSize, int pageSize, int downCacheSize) throws Exception
{
insureStarted();
servers[0].getServer().deployQueue(name, jndiName, fullSize, pageSize, downCacheSize, false);
}
-
+
/**
* Simulates a queue deployment (copying the queue descriptor in the deploy directory).
*/
- public static void deployQueue(String name, String jndiName, int fullSize, int pageSize,
- int downCacheSize, int serverIndex, boolean clustered)
- throws Exception
+ public static void deployQueue(String name,
+ String jndiName,
+ int fullSize,
+ int pageSize,
+ int downCacheSize,
+ int serverIndex,
+ boolean clustered) throws Exception
{
insureStarted();
- servers[serverIndex].getServer().
- deployQueue(name, jndiName, fullSize, pageSize, downCacheSize, clustered);
+ servers[serverIndex].getServer().deployQueue(name, jndiName, fullSize, pageSize, downCacheSize, clustered);
}
/**
+ * Simulates a queue deployment with a DLQ and ExpiryQueue attributes.
+ */
+ public static ObjectName deployQueueWithDLQnExpiryQ(String qName, String DLQName, String ExpiryQName) throws Exception
+ {
+ insureStarted();
+ Server testServer = servers[0].getServer();
+ return servers[0].getServer().deployQueueWithDLQnExpiryQ(qName, DLQName, ExpiryQName);
+ }
+
+ /**
+ * Simulates a topic deployment with a DLQ and ExpiryQueue attributes.
+ */
+ public static ObjectName deployTopicWithDLQnExpiryQ(String topicName, String DLQName, String ExpiryQName) throws Exception
+ {
+ insureStarted();
+ return servers[0].getServer().deployTopicWithDLQnExpiryQ(topicName, DLQName, ExpiryQName);
+ }
+
+ /**
+ * Simulate a queue deployment without starting it.
+ */
+ public static ObjectName deployQueueWithoutStart(String testDLQName) throws Exception
+ {
+ insureStarted();
+ Server testServer = servers[0].getServer();
+ ObjectName name = testServer.deployQueueWithoutStart(testDLQName, null, false);
+ return name;
+ }
+
+ /**
+ * start the service
+ */
+ public static void startDestinationService(ObjectName[] objectNames) throws Exception
+ {
+ insureStarted();
+ servers[0].getServer().startDestinationService(objectNames);
+ }
+
+ /**
* Simulates a queue un-deployment (deleting the queue descriptor from the deploy directory).
*/
public static void undeployQueue(String name) throws Exception
@@ -1087,8 +1104,7 @@
}
/**
- * Simulates a destination un-deployment (deleting the destination descriptor from the deploy
- * directory).
+ * Simulates a destination un-deployment (deleting the destination descriptor from the deploy directory).
*/
private static void undeployDestination(boolean isQueue, String name) throws Exception
{
@@ -1097,11 +1113,9 @@
}
/**
- * Simulates a destination un-deployment (deleting the destination descriptor from the deploy
- * directory).
+ * Simulates a destination un-deployment (deleting the destination descriptor from the deploy directory).
*/
- private static void undeployDestination(boolean isQueue, String name, int serverIndex)
- throws Exception
+ private static void undeployDestination(boolean isQueue, String name, int serverIndex) throws Exception
{
insureStarted(serverIndex);
servers[serverIndex].getServer().undeployDestination(isQueue, name);
@@ -1112,8 +1126,7 @@
int prefetchSize,
int defaultTempQueueFullSize,
int defaultTempQueuePageSize,
- int defaultTempQueueDownCacheSize)
- throws Exception
+ int defaultTempQueueDownCacheSize) throws Exception
{
servers[0].getServer().deployConnectionFactory(objectName,
jndiBindings,
@@ -1124,25 +1137,19 @@
}
public static void deployConnectionFactory(String objectName,
- String[] jndiBindings,
- boolean supportsFailover, boolean supportsLoadBalancing)
- throws Exception
+ String[] jndiBindings,
+ boolean supportsFailover,
+ boolean supportsLoadBalancing) throws Exception
{
- servers[0].getServer().deployConnectionFactory(objectName,
- jndiBindings,supportsFailover, supportsLoadBalancing);
+ servers[0].getServer().deployConnectionFactory(objectName, jndiBindings, supportsFailover, supportsLoadBalancing);
}
- public static void deployConnectionFactory(String objectName,
- String[] jndiBindings,
- int prefetchSize)
- throws Exception
+ public static void deployConnectionFactory(String objectName, String[] jndiBindings, int prefetchSize) throws Exception
{
servers[0].getServer().deployConnectionFactory(objectName, jndiBindings, prefetchSize);
}
- public static void deployConnectionFactory(String objectName,
- String[] jndiBindings)
- throws Exception
+ public static void deployConnectionFactory(String objectName, String[] jndiBindings) throws Exception
{
servers[0].getServer().deployConnectionFactory(objectName, jndiBindings);
}
@@ -1171,9 +1178,10 @@
public static Server acquireRemote(int initialRetries, int index, boolean quiet)
{
- String name =
- "//localhost:" + RMITestServer.DEFAULT_REGISTRY_PORT + "/" +
- RMITestServer.RMI_SERVER_PREFIX + index;
+ String name = "//localhost:" + RMITestServer.DEFAULT_REGISTRY_PORT +
+ "/" +
+ RMITestServer.RMI_SERVER_PREFIX +
+ index;
Server s = null;
int retries = initialRetries;
@@ -1184,7 +1192,7 @@
try
{
String msg = "trying to connect to the remote RMI server " + index +
- (attempt == 1 ? "" : ", attempt " + attempt);
+ (attempt == 1 ? "" : ", attempt " + attempt);
if (quiet)
{
@@ -1199,16 +1207,15 @@
log.debug("connected to remote server " + index);
}
- catch(Exception e)
+ catch (Exception e)
{
- log.debug("failed to get the RMI server stub, attempt " +
- (initialRetries - retries + 1), e);
+ log.debug("failed to get the RMI server stub, attempt " + (initialRetries - retries + 1), e);
try
{
Thread.sleep(500);
}
- catch(InterruptedException e2)
+ catch (InterruptedException e2)
{
// OK
}
@@ -1225,7 +1232,6 @@
insureStarted(serverIndex);
return servers[serverIndex].getServer().getRemotingTransport();
}
-
// Attributes ----------------------------------------------------
@@ -1243,7 +1249,7 @@
{
insureStarted(0);
}
-
+
private static void insureStarted(int i) throws Exception
{
if (servers[i] == null)
@@ -1266,8 +1272,11 @@
public static final int POLL_INTERVAL = 500;
private long id;
+
private Server server;
+
private NotificationListener listener;
+
private volatile boolean running;
private synchronized static long generateID()
@@ -1275,8 +1284,7 @@
return listenerIDCounter++;
}
- NotificationListenerPoller(Server server, ObjectName on, NotificationListener listener)
- throws Exception
+ NotificationListenerPoller(Server server, ObjectName on, NotificationListener listener) throws Exception
{
id = generateID();
this.server = server;
@@ -1289,13 +1297,13 @@
public void run()
{
- while(running)
+ while (running)
{
try
{
List notifications = server.pollNotificationListener(id);
- for(Iterator i = notifications.iterator(); i.hasNext(); )
+ for (Iterator i = notifications.iterator(); i.hasNext();)
{
Notification n = (Notification)i.next();
listener.handleNotification(n, null);
@@ -1303,7 +1311,7 @@
Thread.sleep(POLL_INTERVAL);
}
- catch(Exception e)
+ catch (Exception e)
{
log.error(e);
stop();
@@ -1320,6 +1328,7 @@
private static class ServerHolder
{
private Server server;
+
private boolean spawned;
ServerHolder(Server server, boolean spawned)
Modified: branches/Branch_1_4/tests/src/org/jboss/test/messaging/tools/container/RMITestServer.java
===================================================================
--- branches/Branch_1_4/tests/src/org/jboss/test/messaging/tools/container/RMITestServer.java 2008-09-24 23:08:48 UTC (rev 5023)
+++ branches/Branch_1_4/tests/src/org/jboss/test/messaging/tools/container/RMITestServer.java 2008-09-25 04:52:34 UTC (rev 5024)
@@ -1,24 +1,14 @@
/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
+ * JBoss, Home of Professional Open Source Copyright 2005, JBoss Inc., and individual contributors as indicated by the
+ * @authors tag. See the copyright.txt in the distribution for a full listing of individual contributors. This is free
+ * software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+ * This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details. You should have received a copy of the GNU Lesser General Public License along with this software; if not,
+ * write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
+ */
package org.jboss.test.messaging.tools.container;
import java.rmi.registry.LocateRegistry;
@@ -43,25 +33,27 @@
/**
* An RMI wrapper to access the ServiceContainer from a different address space.
- *
+ *
* @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
* @author <a href="mailto:tim.fox at jboss.com>Tim Fox</a>
- * @version <tt>1.1</tt>
- *
- * RMITestServer.java,v 1.1 2006/02/21 08:25:33 timfox Exp
+ * @version <tt>1.1</tt> RMITestServer.java,v 1.1 2006/02/21 08:25:33 timfox Exp
*/
public class RMITestServer extends UnicastRemoteObject implements Server
{
// Constants -----------------------------------------------------
public static final String RMI_SERVER_PREFIX = "messaging_rmi_server_";
+
public static final String NAMING_SERVER_PREFIX = "naming_rmi_server_";
public static final int DEFAULT_REGISTRY_PORT = 33777;
+
public static final int DEFAULT_SERVER_INDEX = 0;
+
public static final String DEFAULT_SERVER_HOST = "localhost";
private static final long serialVersionUID = -368445344011004778L;
+
private static final Logger log = Logger.getLogger(RMITestServer.class);
// Static --------------------------------------------------------
@@ -103,7 +95,7 @@
registry.bind(RMI_SERVER_PREFIX + serverIndex, testServer);
registry.bind(NAMING_SERVER_PREFIX + serverIndex, testServer.getNamingDelegate());
}
- catch(Exception e)
+ catch (Exception e)
{
log.info("Failure using an existing registry, trying creating it");
@@ -114,13 +106,15 @@
registry.bind(NAMING_SERVER_PREFIX + serverIndex, testServer.getNamingDelegate());
}
- log.info("RMI server " + serverIndex + " bound");
+ log.info("RMI server " + serverIndex + " bound");
}
// Attributes ----------------------------------------------------
protected RemoteTestServer server;
+
private RMINamingDelegate namingDelegate;
+
private Map proxyListeners;
// Constructors --------------------------------------------------
@@ -144,8 +138,10 @@
start(containerConfig, null, clearDatabase, true);
}
- public void start(String containerConfig, ServiceAttributeOverrides attrOverrides,
- boolean clearDatabase, boolean startMessagingServer) throws Exception
+ public void start(String containerConfig,
+ ServiceAttributeOverrides attrOverrides,
+ boolean clearDatabase,
+ boolean startMessagingServer) throws Exception
{
server.start(containerConfig, attrOverrides, clearDatabase, startMessagingServer);
}
@@ -159,7 +155,7 @@
public synchronized void kill() throws Exception
{
- log.info("kill() invoked - first deregistering from the rmi registry");
+ log.info("kill() invoked - first deregistering from the rmi registry");
// unregister myself from the RMI registry
@@ -176,13 +172,13 @@
log.info("unregistered " + name + " from registry");
log.info("Killing VM!!!!");
-
+
Runtime.getRuntime().halt(1);
}
public void ping() throws Exception
{
- //noop - nothing to be done
+ // noop - nothing to be done
}
public ObjectName deploy(String mbeanConfiguration) throws Exception
@@ -205,14 +201,12 @@
server.setAttribute(on, name, valueAsString);
}
- public Object invoke(ObjectName on, String operationName, Object[] params, String[] signature)
- throws Exception
+ public Object invoke(ObjectName on, String operationName, Object[] params, String[] signature) throws Exception
{
return server.invoke(on, operationName, params, signature);
}
- public void addNotificationListener(ObjectName on, NotificationListener listener)
- throws Exception
+ public void addNotificationListener(ObjectName on, NotificationListener listener) throws Exception
{
if (!(listener instanceof NotificationListenerID))
{
@@ -223,7 +217,7 @@
ProxyNotificationListener pl = new ProxyNotificationListener();
- synchronized(proxyListeners)
+ synchronized (proxyListeners)
{
proxyListeners.put(new Long(id), pl);
}
@@ -231,8 +225,7 @@
server.addNotificationListener(on, pl);
}
- public void removeNotificationListener(ObjectName on, NotificationListener listener)
- throws Exception
+ public void removeNotificationListener(ObjectName on, NotificationListener listener) throws Exception
{
if (!(listener instanceof NotificationListenerID))
@@ -244,7 +237,7 @@
ProxyNotificationListener pl = null;
- synchronized(proxyListeners)
+ synchronized (proxyListeners)
{
pl = (ProxyNotificationListener)proxyListeners.remove(new Long(id));
}
@@ -267,21 +260,21 @@
server.log(level, text);
}
- public void startServerPeer(int serverPeerID, String defaultQueueJNDIContext,
- String defaultTopicJNDIContext, boolean clustered) throws Exception
+ public void startServerPeer(int serverPeerID,
+ String defaultQueueJNDIContext,
+ String defaultTopicJNDIContext,
+ boolean clustered) throws Exception
{
- startServerPeer(serverPeerID, defaultQueueJNDIContext,
- defaultTopicJNDIContext, null, clustered);
+ startServerPeer(serverPeerID, defaultQueueJNDIContext, defaultTopicJNDIContext, null, clustered);
}
-
- public void startServerPeer(int serverPeerID, String defaultQueueJNDIContext,
+ public void startServerPeer(int serverPeerID,
+ String defaultQueueJNDIContext,
String defaultTopicJNDIContext,
- ServiceAttributeOverrides attrOverrides, boolean clustered)
- throws Exception
+ ServiceAttributeOverrides attrOverrides,
+ boolean clustered) throws Exception
{
- server.startServerPeer(serverPeerID, defaultQueueJNDIContext,
- defaultTopicJNDIContext, attrOverrides, clustered);
+ server.startServerPeer(serverPeerID, defaultQueueJNDIContext, defaultTopicJNDIContext, attrOverrides, clustered);
}
public void stopServerPeer() throws Exception
@@ -309,8 +302,7 @@
return server.getConnectorSubsystems();
}
- public void addServerInvocationHandler(String subsystem, ServerInvocationHandler handler)
- throws Exception
+ public void addServerInvocationHandler(String subsystem, ServerInvocationHandler handler) throws Exception
{
server.addServerInvocationHandler(subsystem, handler);
}
@@ -390,48 +382,74 @@
return server.undeployDestinationProgrammatically(isQueue, name);
}
- public void deployConnectionFactory(String objectName, String[] jndiBindings)
- throws Exception
+ public void deployConnectionFactory(String objectName, String[] jndiBindings) throws Exception
{
server.deployConnectionFactory(objectName, jndiBindings);
}
- public void deployConnectionFactory(String objectName, String[] jndiBindings, int prefetchSize)
- throws Exception
+ public void deployConnectionFactory(String objectName, String[] jndiBindings, int prefetchSize) throws Exception
{
server.deployConnectionFactory(objectName, jndiBindings, prefetchSize);
}
+ public void deployConnectionFactory(String objectName, String[] jndiBindings, boolean strictTck) throws Exception
+ {
+ server.deployConnectionFactory(objectName, jndiBindings, strictTck);
- public void deployConnectionFactory(String objectName, String[] jndiBindings, boolean strictTck) throws Exception
- {
- server.deployConnectionFactory(objectName, jndiBindings, strictTck);
+ }
- }
-
- public void deployConnectionFactory(String objectName,
+ public void deployConnectionFactory(String objectName,
String[] jndiBindings,
int prefetchSize,
int defaultTempQueueFullSize,
int defaultTempQueuePageSize,
int defaultTempQueueDownCacheSize) throws Exception
{
- server.deployConnectionFactory(objectName, jndiBindings, prefetchSize,
- defaultTempQueueFullSize, defaultTempQueuePageSize, defaultTempQueueDownCacheSize);
+ server.deployConnectionFactory(objectName,
+ jndiBindings,
+ prefetchSize,
+ defaultTempQueueFullSize,
+ defaultTempQueuePageSize,
+ defaultTempQueueDownCacheSize);
}
-
+
public void deployConnectionFactory(String objectName,
- String[] jndiBindings, boolean supportsFailover, boolean supportsLoadBalancing) throws Exception
+ String[] jndiBindings,
+ boolean supportsFailover,
+ boolean supportsLoadBalancing) throws Exception
{
- server.deployConnectionFactory(objectName, jndiBindings, supportsFailover, supportsLoadBalancing);
+ server.deployConnectionFactory(objectName, jndiBindings, supportsFailover, supportsLoadBalancing);
}
-
+
public void deployConnectionFactory(String objectName,
- String[] jndiBindings, boolean supportsFailover, boolean supportsLoadBalancing, String clientID) throws Exception
+ String[] jndiBindings,
+ boolean supportsFailover,
+ boolean supportsLoadBalancing,
+ String clientID) throws Exception
{
server.deployConnectionFactory(objectName, jndiBindings, supportsFailover, supportsLoadBalancing, clientID);
}
+ public ObjectName deployQueueWithDLQnExpiryQ(String q, String dlq, String expq) throws Exception
+ {
+ return server.deployQueueWithDLQnExpiryQ(q, dlq, expq);
+ }
+
+ public ObjectName deployQueueWithoutStart(String testQName, String jndi, boolean b) throws Exception
+ {
+ return server.deployQueueWithoutStart(testQName, jndi, b);
+ }
+
+ public ObjectName deployTopicWithDLQnExpiryQ(String topic, String dlq, String expq) throws Exception
+ {
+ return server.deployTopicWithDLQnExpiryQ(topic, dlq, expq);
+ }
+
+ public void startDestinationService(ObjectName[] objectNames) throws Exception
+ {
+ server.startDestinationService(objectNames);
+ }
+
public void undeployConnectionFactory(ObjectName objectName) throws Exception
{
server.undeployConnectionFactory(objectName);
@@ -466,27 +484,27 @@
{
return server.getNodeIDView();
}
-
+
public Map getFailoverMap() throws Exception
{
- return server.getFailoverMap();
+ return server.getFailoverMap();
}
-
+
public Map getRecoveryArea(String queueName) throws Exception
{
- return server.getRecoveryArea(queueName);
+ return server.getRecoveryArea(queueName);
}
-
+
public int getRecoveryMapSize(String queueName) throws Exception
{
- return server.getRecoveryMapSize(queueName);
+ return server.getRecoveryMapSize(queueName);
}
-
+
public List pollNotificationListener(long listenerID) throws Exception
{
ProxyNotificationListener pl = null;
- synchronized(proxyListeners)
+ synchronized (proxyListeners)
{
pl = (ProxyNotificationListener)proxyListeners.get(new Long(listenerID));
}
@@ -503,17 +521,17 @@
{
server.poisonTheServer(type);
}
-
+
public void flushManagedConnectionPool()
{
- server.flushManagedConnectionPool();
+ server.flushManagedConnectionPool();
}
-
+
public void resetAllSuckers() throws Exception
{
- server.resetAllSuckers();
- }
-
+ server.resetAllSuckers();
+ }
+
// Public --------------------------------------------------------
// Package protected ---------------------------------------------
Modified: branches/Branch_1_4/tests/src/org/jboss/test/messaging/tools/container/Server.java
===================================================================
--- branches/Branch_1_4/tests/src/org/jboss/test/messaging/tools/container/Server.java 2008-09-24 23:08:48 UTC (rev 5023)
+++ branches/Branch_1_4/tests/src/org/jboss/test/messaging/tools/container/Server.java 2008-09-25 04:52:34 UTC (rev 5024)
@@ -1,24 +1,14 @@
/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
+ * JBoss, Home of Professional Open Source Copyright 2005, JBoss Inc., and individual contributors as indicated by the
+ * @authors tag. See the copyright.txt in the distribution for a full listing of individual contributors. This is free
+ * software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+ * This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details. You should have received a copy of the GNU Lesser General Public License along with this software; if not,
+ * write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
+ */
package org.jboss.test.messaging.tools.container;
import java.rmi.Remote;
@@ -38,11 +28,9 @@
/**
* The remote interface exposed by TestServer.
- *
+ *
* @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @version <tt>$Revision: 2868 $</tt>
- *
- * $Id: Server.java 2868 2007-07-10 20:22:16Z timfox $
+ * @version <tt>$Revision: 2868 $</tt> $Id: Server.java 2868 2007-07-10 20:22:16Z timfox $
*/
public interface Server extends Remote
{
@@ -51,8 +39,8 @@
void start(String containerConfig, boolean clearDatabase) throws Exception;
/**
- * @param attrOverrides - service attribute overrides that will take precedence over values
- * read from configuration files.
+ * @param attrOverrides - service attribute overrides that will take precedence over values read from configuration
+ * files.
*/
void start(String containerConfig,
ServiceAttributeOverrides attrOverrides,
@@ -60,29 +48,27 @@
boolean startMessgingServer) throws Exception;
/**
- * @return true if the server was stopped indeed, or false if the server was stopped already
- * when the method was invoked.
+ * @return true if the server was stopped indeed, or false if the server was stopped already when the method was
+ * invoked.
*/
boolean stop() throws Exception;
/**
- * For a remote server, it "abruptly" kills the VM running the server. For a local server
- * it just stops the server.
+ * For a remote server, it "abruptly" kills the VM running the server. For a local server it just stops the server.
*/
void kill() throws Exception;
/**
- * When kill is called you are actually schedulling the server to be killed in few milliseconds.
- * There are certain cases where we need to assure the server was really killed.
- * For that we have this simple ping we can use to verify if the server still alive or not.
+ * When kill is called you are actually schedulling the server to be killed in few milliseconds. There are certain
+ * cases where we need to assure the server was really killed. For that we have this simple ping we can use to verify
+ * if the server still alive or not.
*/
void ping() throws Exception;
/**
- * Deploys and registers a service based on the MBean service descriptor element, specified as
- * a String. Supports XMBeans. The implementing class and the ObjectName are inferred from the
- * mbean element. If there are configuration attributed specified in the deployment descriptor,
- * they are applied to the service instance.
+ * Deploys and registers a service based on the MBean service descriptor element, specified as a String. Supports
+ * XMBeans. The implementing class and the ObjectName are inferred from the mbean element. If there are configuration
+ * attributed specified in the deployment descriptor, they are applied to the service instance.
*/
ObjectName deploy(String mbeanConfiguration) throws Exception;
@@ -92,8 +78,7 @@
void setAttribute(ObjectName on, String name, String valueAsString) throws Exception;
- Object invoke(ObjectName on, String operationName, Object[] params, String[] signature)
- throws Exception;
+ Object invoke(ObjectName on, String operationName, Object[] params, String[] signature) throws Exception;
void addNotificationListener(ObjectName on, NotificationListener listener) throws Exception;
@@ -134,21 +119,20 @@
boolean isStarted() throws Exception;
/**
- * @return a Set<String> with the subsystems currently registered with the Connector. It is
- * supposed to work locally as well as remotely.
+ * @return a Set<String> with the subsystems currently registered with the Connector. It is supposed to work locally
+ * as well as remotely.
*/
Set getConnectorSubsystems() throws Exception;
/**
- * Add a ServerInvocationHandler to the remoting Connector. This method is supposed to work
- * locally as well as remotely.
+ * Add a ServerInvocationHandler to the remoting Connector. This method is supposed to work locally as well as
+ * remotely.
*/
- void addServerInvocationHandler(String subsystem, ServerInvocationHandler handler)
- throws Exception;
+ void addServerInvocationHandler(String subsystem, ServerInvocationHandler handler) throws Exception;
/**
- * Remove a ServerInvocationHandler from the remoting Connector. This method is supposed to work
- * locally as well as remotely.
+ * Remove a ServerInvocationHandler from the remoting Connector. This method is supposed to work locally as well as
+ * remotely.
*/
void removeServerInvocationHandler(String subsystem) throws Exception;
@@ -177,8 +161,7 @@
/**
* Simulates a topic deployment (copying the topic descriptor in the deploy directory).
*/
- void deployTopic(String name, String jndiName, int fullSize, int pageSize,
- int downCacheSize, boolean clustered) throws Exception;
+ void deployTopic(String name, String jndiName, int fullSize, int pageSize, int downCacheSize, boolean clustered) throws Exception;
/**
* Creates a topic programatically.
@@ -193,8 +176,7 @@
/**
* Simulates a queue deployment (copying the queue descriptor in the deploy directory).
*/
- void deployQueue(String name, String jndiName, int fullSize, int pageSize,
- int downCacheSize, boolean clustered) throws Exception;
+ void deployQueue(String name, String jndiName, int fullSize, int pageSize, int downCacheSize, boolean clustered) throws Exception;
/**
* Creates a queue programatically.
@@ -202,9 +184,34 @@
void deployQueueProgrammatically(String name, String jndiName) throws Exception;
/**
- * Simulates a destination un-deployment (deleting the destination descriptor from the deploy
- * directory).
+ * Creates a queue deployment with the DLQ and ExpiryQueue attributes. this method doesn't start the mbean service.
+ * Rather it returns the ObjectName of the mbean service.
+ *
+ * @throws Exception
*/
+ ObjectName deployQueueWithDLQnExpiryQ(String q, String dlq, String expq) throws Exception;
+
+ /**
+ * Creates a topic deployment with the DLQ and ExpiryQueue attributes. this method doesn't start the mbean service.
+ * Rather it returns the ObjectName of the mbean service.
+ *
+ * @throws Exception
+ */
+ ObjectName deployTopicWithDLQnExpiryQ(String topic, String dlq, String expq) throws Exception;
+
+ /**
+ * Create a queue deployment without starting it.
+ */
+ ObjectName deployQueueWithoutStart(String testDLQName, String jndi, boolean b) throws Exception;
+
+ /**
+ * Starts the deployed the services.
+ */
+ void startDestinationService(ObjectName[] objectNames) throws Exception;
+
+ /**
+ * Simulates a destination un-deployment (deleting the destination descriptor from the deploy directory).
+ */
void undeployDestination(boolean isQueue, String name) throws Exception;
/**
@@ -217,46 +224,39 @@
int prefetchSize,
int defaultTempQueueFullSize,
int defaultTempQueuePageSize,
- int defaultTempQueueDownCacheSize
- ) throws Exception;
-
- void deployConnectionFactory(String objectName,
- String[] jndiBindings,
- boolean supportsFailover,
- boolean supportsLoadBalancing
- ) throws Exception;
-
- void deployConnectionFactory(String objectName,
- String[] jndiBindings,
- boolean supportsFailover,
- boolean supportsLoadBalancing,
- String clientID
- ) throws Exception;
+ int defaultTempQueueDownCacheSize) throws Exception;
void deployConnectionFactory(String objectName,
String[] jndiBindings,
- int prefetchSize) throws Exception;
+ boolean supportsFailover,
+ boolean supportsLoadBalancing) throws Exception;
void deployConnectionFactory(String objectName,
- String[] jndiBindings) throws Exception;
+ String[] jndiBindings,
+ boolean supportsFailover,
+ boolean supportsLoadBalancing,
+ String clientID) throws Exception;
+ void deployConnectionFactory(String objectName, String[] jndiBindings, int prefetchSize) throws Exception;
+
+ void deployConnectionFactory(String objectName, String[] jndiBindings) throws Exception;
+
void undeployConnectionFactory(ObjectName objectName) throws Exception;
/**
- * @param config - sending 'config' as a String and not as an org.w3c.dom.Element to avoid
- * NotSerializableExceptions that show up when running tests on JDK 1.4.
+ * @param config - sending 'config' as a String and not as an org.w3c.dom.Element to avoid NotSerializableExceptions
+ * that show up when running tests on JDK 1.4.
*/
void configureSecurityForDestination(String destName, String config) throws Exception;
/**
- * @param config - sending 'config' as a String and not as an org.w3c.dom.Element to avoid
- * NotSerializableExceptions that show up when running tests on JDK 1.4.
+ * @param config - sending 'config' as a String and not as an org.w3c.dom.Element to avoid NotSerializableExceptions
+ * that show up when running tests on JDK 1.4.
*/
void setDefaultSecurityConfig(String config) throws Exception;
/**
- * @return a String that can be converted to an org.w3c.dom.Element using
- * ServerManagement.toElement().
+ * @return a String that can be converted to an org.w3c.dom.Element using ServerManagement.toElement().
*/
String getDefaultSecurityConfig() throws Exception;
@@ -272,17 +272,15 @@
UserTransaction getUserTransaction() throws Exception;
/**
- * Returns a Set containing the nodeID (as Integers) of all cluster members at the time of the
- * call.
- *
- * USE IT ONLY FOR CLUSTERING TESTS!
+ * Returns a Set containing the nodeID (as Integers) of all cluster members at the time of the call. USE IT ONLY FOR
+ * CLUSTERING TESTS!
*/
Set getNodeIDView() throws Exception;
-
+
Map getFailoverMap() throws Exception;
-
+
Map getRecoveryArea(String queueName) throws Exception;
-
+
int getRecoveryMapSize(String queueName) throws Exception;
/**
@@ -291,10 +289,11 @@
List pollNotificationListener(long listenerID) throws Exception;
void poisonTheServer(int type) throws Exception;
-
+
void flushManagedConnectionPool() throws Exception;
-
- void resetAllSuckers() throws Exception;
-
+
+ void resetAllSuckers() throws Exception;
+
void deployConnectionFactory(String objectName, String[] jndiBindings, boolean strictTck) throws Exception;
+
}
More information about the jboss-cvs-commits
mailing list