[jboss-cvs] JBoss Messaging SVN: r5817 - in branches/Branch_1416_merge: src/main/org/jboss/messaging/core/impl and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Feb 5 05:02:58 EST 2009
Author: gaohoward
Date: 2009-02-05 05:02:58 -0500 (Thu, 05 Feb 2009)
New Revision: 5817
Modified:
branches/Branch_1416_merge/integration/EAP4/etc/xmdesc/ConnectionFactory-xmbean.xml
branches/Branch_1416_merge/src/main/org/jboss/messaging/core/impl/OrderingGroup.java
branches/Branch_1416_merge/tests/src/org/jboss/test/messaging/jms/ConnectionFactoryTest.java
Log:
add connection factory ordering group configuration tests
Modified: branches/Branch_1416_merge/integration/EAP4/etc/xmdesc/ConnectionFactory-xmbean.xml
===================================================================
--- branches/Branch_1416_merge/integration/EAP4/etc/xmdesc/ConnectionFactory-xmbean.xml 2009-02-05 06:08:30 UTC (rev 5816)
+++ branches/Branch_1416_merge/integration/EAP4/etc/xmdesc/ConnectionFactory-xmbean.xml 2009-02-05 10:02:58 UTC (rev 5817)
@@ -129,6 +129,24 @@
<name>DisableRemotingChecks</name>
<type>boolean</type>
</attribute>
+
+ <attribute access="read-write" getMethod="isDisableRemotingChecks" setMethod="setDisableRemotingChecks">
+ <description>Disable remoting connector parameter sanity checks. There is rarely a good reason to set this to true</description>
+ <name>DisableRemotingChecks</name>
+ <type>boolean</type>
+ </attribute>
+
+ <attribute access="read-write" getMethod="isEnableOrderingGroup" setMethod="setEnableOrderingGroup">
+ <description>Enable/Disable message ordering group on connection factory. Default is false.</description>
+ <name>EnableOrderingGroup</name>
+ <type>boolean</type>
+ </attribute>
+
+ <attribute access="read-write" getMethod="getDefaultOrderingGroupName" setMethod="setDefaultOrderingGroupName">
+ <description>The default name for message ordering group, only make sense when ordering group is enabled on the connection factory.</description>
+ <name>DefaultOrderingGroupName</name>
+ <type>java.lang.String</type>
+ </attribute>
<!-- Managed operations -->
@@ -152,4 +170,4 @@
<name>destroy</name>
</operation>
-</mbean>
\ No newline at end of file
+</mbean>
Modified: branches/Branch_1416_merge/src/main/org/jboss/messaging/core/impl/OrderingGroup.java
===================================================================
--- branches/Branch_1416_merge/src/main/org/jboss/messaging/core/impl/OrderingGroup.java 2009-02-05 06:08:30 UTC (rev 5816)
+++ branches/Branch_1416_merge/src/main/org/jboss/messaging/core/impl/OrderingGroup.java 2009-02-05 10:02:58 UTC (rev 5817)
@@ -23,13 +23,11 @@
package org.jboss.messaging.core.impl;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import javax.jms.JMSException;
-import org.jboss.jms.message.JBossMessage;
import org.jboss.logging.Logger;
import org.jboss.messaging.core.contract.MessageReference;
Modified: branches/Branch_1416_merge/tests/src/org/jboss/test/messaging/jms/ConnectionFactoryTest.java
===================================================================
--- branches/Branch_1416_merge/tests/src/org/jboss/test/messaging/jms/ConnectionFactoryTest.java 2009-02-05 06:08:30 UTC (rev 5816)
+++ branches/Branch_1416_merge/tests/src/org/jboss/test/messaging/jms/ConnectionFactoryTest.java 2009-02-05 10:02:58 UTC (rev 5817)
@@ -38,13 +38,16 @@
import javax.management.ObjectName;
import org.jboss.jms.client.JBossConnectionFactory;
+import org.jboss.jms.client.JBossMessageProducer;
import org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate;
+import org.jboss.jms.message.JBossMessage;
import org.jboss.test.messaging.tools.ServerManagement;
import org.jboss.test.messaging.tools.container.ServiceContainer;
/**
* @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:hgao at redhat.com">Howard Gao</a>
* @version <tt>$Revision$</tt>
*
* $Id$
@@ -618,6 +621,241 @@
}
+ /**
+ * This is test the configuration of ordering group on connection factories
+ * First it deployed a connection factory with ordering group disabled, then use the factory to
+ * send messages. then check the message at the receiving end to make sure the
+ * configuration really take effect.
+ *
+ * Also it tests the connection factory with the ordering group related parameters absent.
+ * in which case the effect should be same as the above.
+ */
+ public void testAdministrativelyConfiguredNoOrderingGroup() throws Exception
+ {
+ Connection c = null;
+ Connection c2 = null;
+
+ try
+ {
+ String mbeanConfig = "<mbean code=\"org.jboss.jms.server.connectionfactory.ConnectionFactory\"\n" + " name=\"jboss.messaging.connectionfactory:service=TestNoOrderingGroupConnectionFactory\"\n"
+ + " xmbean-dd=\"xmdesc/ConnectionFactory-xmbean.xml\">\n"
+ + " <depends optional-attribute-name=\"ServerPeer\">jboss.messaging:service=ServerPeer</depends>\n"
+ + " <depends optional-attribute-name=\"Connector\">jboss.messaging:service=Connector,transport=bisocket</depends>\n"
+ + " <attribute name=\"JNDIBindings\">\n"
+ + " <bindings>\n"
+ + " <binding>/TestNoOrderingGroupConnectionFactory</binding>\n"
+ + " </bindings>\n"
+ + " </attribute>\n"
+ + " <attribute name=\"EnableOrderingGroup\">false</attribute>\n"
+ + " <attribute name=\"DefaultOrderingGroupName\">MyOrderingGroup</attribute>\n"
+ + " </mbean>";
+
+ ObjectName on = ServerManagement.deploy(mbeanConfig);
+ ServerManagement.invoke(on, "create", new Object[0], new String[0]);
+ ServerManagement.invoke(on, "start", new Object[0], new String[0]);
+
+ ConnectionFactory cf = (ConnectionFactory)ic.lookup("/TestNoOrderingGroupConnectionFactory");
+ c = cf.createConnection();
+
+ Session session = c.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageProducer prod = session.createProducer(queue1);
+
+ final int NUM_MSG = 1000;
+
+ for (int i = 1; i < NUM_MSG; i++)
+ {
+ TextMessage tm = session.createTextMessage("message " + i);
+ prod.send(tm);
+ }
+
+ c.start();
+
+ MessageConsumer consmr = session.createConsumer(queue1);
+
+ for (int i = 1; i < NUM_MSG; i++)
+ {
+ TextMessage rm = (TextMessage)consmr.receive(500);
+ assertNotNull(rm);
+ // each message should not have the header.
+ String orderingGroupName = rm.getStringProperty(JBossMessage.JBOSS_MESSAGING_ORDERING_GROUP_ID);
+ assertNull(orderingGroupName);
+ }
+
+ session.close();
+
+ String mbeanConfig2 = "<mbean code=\"org.jboss.jms.server.connectionfactory.ConnectionFactory\"\n" + " name=\"jboss.messaging.connectionfactory:service=TestNoOrderingGroupConnectionFactory2\"\n"
+ + " xmbean-dd=\"xmdesc/ConnectionFactory-xmbean.xml\">\n"
+ + " <depends optional-attribute-name=\"ServerPeer\">jboss.messaging:service=ServerPeer</depends>\n"
+ + " <depends optional-attribute-name=\"Connector\">jboss.messaging:service=Connector,transport=bisocket</depends>\n"
+ + " <attribute name=\"JNDIBindings\">\n"
+ + " <bindings>\n"
+ + " <binding>/TestNoOrderingGroupConnectionFactory2</binding>\n"
+ + " </bindings>\n"
+ + " </attribute>\n"
+ + " </mbean>";
+
+ ObjectName on2 = ServerManagement.deploy(mbeanConfig2);
+ ServerManagement.invoke(on2, "create", new Object[0], new String[0]);
+ ServerManagement.invoke(on2, "start", new Object[0], new String[0]);
+
+ ConnectionFactory cf2 = (ConnectionFactory)ic.lookup("/TestNoOrderingGroupConnectionFactory2");
+ c2 = cf2.createConnection();
+
+ Session session2 = c2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageProducer prod2 = session2.createProducer(queue1);
+
+ for (int i = 1; i < NUM_MSG; i++)
+ {
+ TextMessage tm = session2.createTextMessage("message " + i);
+ prod2.send(tm);
+ }
+
+ c2.start();
+
+ MessageConsumer consmr2 = session2.createConsumer(queue1);
+
+ for (int i = 1; i < NUM_MSG; i++)
+ {
+ TextMessage rm = (TextMessage)consmr2.receive(500);
+ assertNotNull(rm);
+ // each message should not have the header.
+ String orderingGroupName = rm.getStringProperty(JBossMessage.JBOSS_MESSAGING_ORDERING_GROUP_ID);
+ assertNull(orderingGroupName);
+ }
+
+ ServerManagement.invoke(on, "stop", new Object[0], new String[0]);
+ ServerManagement.invoke(on, "destroy", new Object[0], new String[0]);
+ ServerManagement.undeploy(on);
+
+ ServerManagement.invoke(on2, "stop", new Object[0], new String[0]);
+ ServerManagement.invoke(on2, "destroy", new Object[0], new String[0]);
+ ServerManagement.undeploy(on2);
+ }
+ finally
+ {
+ try
+ {
+ if (c != null)
+ {
+ log.info("Closing connection");
+ c.close();
+ log.info("Closed connection");
+ }
+ if (c2 != null)
+ {
+ log.info("Closing connection");
+ c2.close();
+ log.info("Closed connection");
+ }
+ }
+ catch (Exception e)
+ {
+ log.warn(e.toString(), e);
+ }
+ }
+ }
+
+
+ /**
+ * This is test the configuration of ordering group on connection factories
+ * First it deployed a ordering-group configured factory, then use the factory to
+ * send messages. then check the message at the receiving end to make sure the
+ * configuration really take effect.
+ */
+ public void testAdministrativelyConfiguredOrderingGroup() throws Exception
+ {
+ Connection c = null;
+
+ try
+ {
+ String mbeanConfig = "<mbean code=\"org.jboss.jms.server.connectionfactory.ConnectionFactory\"\n" + " name=\"jboss.messaging.connectionfactory:service=TestOrderingGroupConnectionFactory\"\n"
+ + " xmbean-dd=\"xmdesc/ConnectionFactory-xmbean.xml\">\n"
+ + " <depends optional-attribute-name=\"ServerPeer\">jboss.messaging:service=ServerPeer</depends>\n"
+ + " <depends optional-attribute-name=\"Connector\">jboss.messaging:service=Connector,transport=bisocket</depends>\n"
+ + " <attribute name=\"JNDIBindings\">\n"
+ + " <bindings>\n"
+ + " <binding>/TestOrderingGroupConnectionFactory</binding>\n"
+ + " </bindings>\n"
+ + " </attribute>\n"
+ + " <attribute name=\"EnableOrderingGroup\">true</attribute>\n"
+ + " <attribute name=\"DefaultOrderingGroupName\">MyOrderingGroup2</attribute>\n"
+ + " </mbean>";
+
+ ObjectName on = ServerManagement.deploy(mbeanConfig);
+ ServerManagement.invoke(on, "create", new Object[0], new String[0]);
+ ServerManagement.invoke(on, "start", new Object[0], new String[0]);
+
+ ConnectionFactory cf = (ConnectionFactory)ic.lookup("/TestOrderingGroupConnectionFactory");
+ c = cf.createConnection();
+
+ Session session = c.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageProducer prod = session.createProducer(queue1);
+
+ final int NUM_MSG = 1000;
+
+ for (int i = 1; i < NUM_MSG; i++)
+ {
+ TextMessage tm = session.createTextMessage("message " + i);
+ prod.send(tm);
+ }
+
+ c.start();
+
+ MessageConsumer consmr = session.createConsumer(queue1);
+
+ for (int i = 1; i < NUM_MSG; i++)
+ {
+ TextMessage rm = (TextMessage)consmr.receive(500);
+ assertNotNull(rm);
+ // each message should have the header.
+ String orderingGroupName = rm.getStringProperty(JBossMessage.JBOSS_MESSAGING_ORDERING_GROUP_ID);
+ assertNotNull(orderingGroupName);
+ assertEquals("MyOrderingGroup2", orderingGroupName);
+ }
+
+ //this tests that factory defaults can be overridden.
+ JBossMessageProducer jProd = (JBossMessageProducer)prod;
+ jProd.enableOrderingGroup("MyAnotherOrderingGroup");
+
+ for (int i = 1; i < NUM_MSG; i++)
+ {
+ TextMessage tm = session.createTextMessage("message " + i);
+ jProd.send(tm);
+ }
+
+ for (int i = 1; i < NUM_MSG; i++)
+ {
+ TextMessage rm = (TextMessage)consmr.receive(500);
+ assertNotNull(rm);
+ // each message should have the header.
+ String orderingGroupName = rm.getStringProperty(JBossMessage.JBOSS_MESSAGING_ORDERING_GROUP_ID);
+ assertNotNull(orderingGroupName);
+ assertEquals("MyAnotherOrderingGroup", orderingGroupName);
+ }
+
+ session.close();
+ ServerManagement.invoke(on, "stop", new Object[0], new String[0]);
+ ServerManagement.invoke(on, "destroy", new Object[0], new String[0]);
+ ServerManagement.undeploy(on);
+ }
+ finally
+ {
+ try
+ {
+ if (c != null)
+ {
+ log.info("Closing connection");
+ c.close();
+ log.info("Closed connection");
+ }
+ }
+ catch (Exception e)
+ {
+ log.warn(e.toString(), e);
+ }
+ }
+ }
+
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
More information about the jboss-cvs-commits
mailing list