[jboss-cvs] JBoss Messaging SVN: r3183 - in trunk: src/main/org/jboss/jms/client/delegate and 5 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Oct 9 07:58:42 EDT 2007
Author: timfox
Date: 2007-10-09 07:58:41 -0400 (Tue, 09 Oct 2007)
New Revision: 3183
Modified:
trunk/src/etc/xmdesc/ServerPeer-xmbean.xml
trunk/src/main/org/jboss/jms/client/delegate/ClientSessionDelegate.java
trunk/src/main/org/jboss/jms/client/state/ProducerState.java
trunk/src/main/org/jboss/jms/server/ServerPeer.java
trunk/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactoryJNDIMapper.java
trunk/src/main/org/jboss/jms/server/endpoint/ServerSessionEndpoint.java
trunk/tests/src/org/jboss/test/messaging/jms/CTSMiscellaneousTest.java
Log:
Extended strictTck implementation
Modified: trunk/src/etc/xmdesc/ServerPeer-xmbean.xml
===================================================================
--- trunk/src/etc/xmdesc/ServerPeer-xmbean.xml 2007-10-08 18:42:44 UTC (rev 3182)
+++ trunk/src/etc/xmdesc/ServerPeer-xmbean.xml 2007-10-09 11:58:41 UTC (rev 3183)
@@ -212,6 +212,12 @@
<type>boolean</type>
</attribute>
+ <attribute access="read-write" getMethod="isStrictTck" setMethod="setStrictTck">
+ <description>Should strict TCK behaviour be always followed?</description>
+ <name>StrictTck</name>
+ <type>boolean</type>
+ </attribute>
+
<attribute access="write-only" setMethod="setSuckerPassword">
<description>The password used for message suckers</description>
<name>SuckerPassword</name>
Modified: trunk/src/main/org/jboss/jms/client/delegate/ClientSessionDelegate.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/delegate/ClientSessionDelegate.java 2007-10-08 18:42:44 UTC (rev 3182)
+++ trunk/src/main/org/jboss/jms/client/delegate/ClientSessionDelegate.java 2007-10-09 11:58:41 UTC (rev 3183)
@@ -30,6 +30,7 @@
import javax.jms.MessageListener;
import javax.transaction.xa.XAResource;
+import org.jboss.jms.client.remoting.JMSRemotingConnection;
import org.jboss.jms.client.state.ConnectionState;
import org.jboss.jms.client.state.HierarchicalState;
import org.jboss.jms.client.state.SessionState;
@@ -90,6 +91,8 @@
// Attributes -----------------------------------------------------------------------------------
private int dupsOKBatchSize;
+
+ private boolean strictTck;
// Static ---------------------------------------------------------------------------------------
@@ -121,17 +124,23 @@
// synchronize (recursively) the client-side state
state.synchronizeWith(newDelegate.getState());
+
+ JMSRemotingConnection conn = ((ConnectionState)state.getParent()).getRemotingConnection();
- client = ((ConnectionState)state.getParent()).getRemotingConnection().
- getRemotingClient();
+ client = conn.getRemotingClient();
+
+ strictTck = conn.isStrictTck();
}
public void setState(HierarchicalState state)
{
super.setState(state);
+
+ JMSRemotingConnection conn = ((ConnectionState)state.getParent()).getRemotingConnection();
- client = ((ConnectionState)state.getParent()).getRemotingConnection().
- getRemotingClient();
+ client = conn.getRemotingClient();
+
+ strictTck = conn.isStrictTck();
}
// Closeable implementation ---------------------------------------------------------------------
@@ -444,14 +453,17 @@
public void send(JBossMessage m, boolean checkForDuplicates) throws JMSException
{
long seq;
- if (m.isReliable())
+
+ if (m.isReliable() || strictTck)
{
seq = -1;
}
else
{
SessionState sstate = (SessionState)state;
+
seq = sstate.getNPSendSequence();
+
sstate.incNpSendSequence();
}
Modified: trunk/src/main/org/jboss/jms/client/state/ProducerState.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/state/ProducerState.java 2007-10-08 18:42:44 UTC (rev 3182)
+++ trunk/src/main/org/jboss/jms/client/state/ProducerState.java 2007-10-09 11:58:41 UTC (rev 3183)
@@ -56,6 +56,7 @@
private int priority = 4;
private long timeToLive = 0;
private int deliveryMode = DeliveryMode.PERSISTENT;
+ private int strictTCK; // cache here
private SessionState parent;
private ProducerDelegate delegate;
Modified: trunk/src/main/org/jboss/jms/server/ServerPeer.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/ServerPeer.java 2007-10-08 18:42:44 UTC (rev 3182)
+++ trunk/src/main/org/jboss/jms/server/ServerPeer.java 2007-10-09 11:58:41 UTC (rev 3183)
@@ -150,6 +150,12 @@
private long recoverDeliveriesTimeout = 5 * 60 * 1000;
private String suckerPassword;
+
+ //Global override for strict behaviour
+ private boolean strictTck;
+
+ //From a system property - this overrides
+ private boolean strictTckProperty;
// wired components
@@ -234,6 +240,8 @@
jmsUserManager = (JMSUserManager)JMXAccessor.getJMXAttributeOverSecurity(mbeanServer, jmsUserManagerObjectName, "Instance");
+ strictTckProperty = "true".equalsIgnoreCase(System.getProperty("jboss.messaging.stricttck"));
+
// We get references to some plugins lazily to avoid problems with circular MBean
// dependencies
@@ -706,6 +714,16 @@
this.suckerPassword = password;
}
+ public void setStrictTck(boolean strictTck)
+ {
+ this.strictTck = strictTck || strictTckProperty;
+ }
+
+ public boolean isStrictTck()
+ {
+ return strictTck || strictTckProperty;
+ }
+
public void enableMessageCounters()
{
messageCounterManager.start();
Modified: trunk/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactoryJNDIMapper.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactoryJNDIMapper.java 2007-10-08 18:42:44 UTC (rev 3182)
+++ trunk/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactoryJNDIMapper.java 2007-10-09 11:58:41 UTC (rev 3183)
@@ -51,7 +51,6 @@
import org.jboss.messaging.core.contract.ClusterNotification;
import org.jboss.messaging.core.contract.ClusterNotificationListener;
import org.jboss.messaging.core.contract.Replicator;
-import org.jboss.messaging.util.GUIDGenerator;
import org.jboss.messaging.util.JNDIUtil;
import org.jboss.messaging.util.Version;
@@ -165,10 +164,13 @@
}
boolean creatingClustered = (supportsFailover || supportsLoadBalancing) && replicator != null;
+
+ //The server peer strict setting overrides the connection factory
+ boolean useStrict = serverPeer.isStrictTck() || strictTck;
ClientConnectionFactoryDelegate localDelegate =
new ClientConnectionFactoryDelegate(uniqueName, id, serverPeer.getServerPeerID(),
- locatorURI, version, clientPing, strictTck);
+ locatorURI, version, clientPing, useStrict);
log.debug(this + " created local delegate " + localDelegate);
Modified: trunk/src/main/org/jboss/jms/server/endpoint/ServerSessionEndpoint.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/ServerSessionEndpoint.java 2007-10-08 18:42:44 UTC (rev 3182)
+++ trunk/src/main/org/jboss/jms/server/endpoint/ServerSessionEndpoint.java 2007-10-09 11:58:41 UTC (rev 3183)
@@ -380,7 +380,7 @@
{
try
{
- if (!message.isReliable())
+ if (thisSequence != -1)
{
//Need to make sure it is in correct order since np messages are sent
//one way so they can arrive out of sequence
Modified: trunk/tests/src/org/jboss/test/messaging/jms/CTSMiscellaneousTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/CTSMiscellaneousTest.java 2007-10-08 18:42:44 UTC (rev 3182)
+++ trunk/tests/src/org/jboss/test/messaging/jms/CTSMiscellaneousTest.java 2007-10-09 11:58:41 UTC (rev 3183)
@@ -1,28 +1,29 @@
/*
- * 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;
import javax.jms.BytesMessage;
import javax.jms.Connection;
+import javax.jms.DeliveryMode;
import javax.jms.InvalidSelectorException;
import javax.jms.Message;
import javax.jms.MessageConsumer;
@@ -57,255 +58,293 @@
*/
public class CTSMiscellaneousTest extends JMSTestCase
{
- // Constants -----------------------------------------------------
+ // Constants -----------------------------------------------------
- // Static --------------------------------------------------------
+ // Static --------------------------------------------------------
- // Attributes ----------------------------------------------------
- protected static JBossConnectionFactory cf;
- protected ServiceAttributeOverrides overrides;
- private static final String ORG_JBOSS_MESSAGING_SERVICE_LBCONNECTION_FACTORY = "org.jboss.messaging:service=StrictTckConnectionFactory";
+ // Attributes ----------------------------------------------------
+ protected static JBossConnectionFactory cf;
+ protected ServiceAttributeOverrides overrides;
+ private static final String ORG_JBOSS_MESSAGING_SERVICE_LBCONNECTION_FACTORY = "org.jboss.messaging:service=StrictTckConnectionFactory";
- // Constructors --------------------------------------------------
+ // Constructors --------------------------------------------------
- public CTSMiscellaneousTest(String name)
- {
- super(name);
- }
+ public CTSMiscellaneousTest(String name)
+ {
+ super(name);
+ }
- protected void setUp() throws Exception
- {
- try
- {
- super.setUp();
- //Deploy a connection factory with load balancing but no failover on node0
- ServerManagement.getServer(0).deployConnectionFactory(ORG_JBOSS_MESSAGING_SERVICE_LBCONNECTION_FACTORY,
- new String[] { "/StrictTCKConnectionFactory" }, true);
- cf = (JBossConnectionFactory) ic.lookup("/StrictTCKConnectionFactory");
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
+ protected void setUp() throws Exception
+ {
+ try
+ {
+ super.setUp();
+ //Deploy a connection factory with load balancing but no failover on node0
+ ServerManagement.getServer(0).deployConnectionFactory(ORG_JBOSS_MESSAGING_SERVICE_LBCONNECTION_FACTORY,
+ new String[] { "/StrictTCKConnectionFactory" }, true);
+ cf = (JBossConnectionFactory) ic.lookup("/StrictTCKConnectionFactory");
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
- }
+ }
- // Public --------------------------------------------------------
+ // Public --------------------------------------------------------
- public void testForiengMessageSetDestination() throws Exception
- {
- Connection c = null;
+ public void testForiengMessageSetDestination() throws Exception
+ {
+ Connection c = null;
- try
- {
- c = cf.createConnection();
- Session s = c.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ try
+ {
+ c = cf.createConnection();
+ Session s = c.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageProducer p = s.createProducer(queue1);
+ MessageProducer p = s.createProducer(queue1);
- // create a Bytes foreign message
- SimpleJMSTextMessage txt = new SimpleJMSTextMessage("hello from Brazil!");
- txt.setJMSDestination(null);
+ // create a Bytes foreign message
+ SimpleJMSTextMessage txt = new SimpleJMSTextMessage("hello from Brazil!");
+ txt.setJMSDestination(null);
- p.send(txt);
+ p.send(txt);
- assertNotNull(txt.getJMSDestination());
+ assertNotNull(txt.getJMSDestination());
- MessageConsumer cons = s.createConsumer(queue1);
- c.start();
+ MessageConsumer cons = s.createConsumer(queue1);
+ c.start();
- TextMessage tm = (TextMessage)cons.receive();
- assertNotNull(tm);
- assertEquals("hello from Brazil!", txt.getText());
- }
- catch(Exception e)
- {
- e.printStackTrace();
- }
- finally
- {
- if (c != null)
- {
- c.close();
- }
- }
+ TextMessage tm = (TextMessage)cons.receive();
+ assertNotNull(tm);
+ assertEquals("hello from Brazil!", txt.getText());
+ }
+ catch(Exception e)
+ {
+ e.printStackTrace();
+ }
+ finally
+ {
+ if (c != null)
+ {
+ c.close();
+ }
+ }
- }
+ }
- public void testForeignByteMessage() throws Exception
- {
- Connection c = null;
-
- try
- {
- c = cf.createConnection();
- Session s = c.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageProducer p = s.createProducer(queue1);
-
- // create a Bytes foreign message
- SimpleJMSBytesMessage bfm = new SimpleJMSBytesMessage();
-
- p.send(bfm);
-
- MessageConsumer cons = s.createConsumer(queue1);
- c.start();
-
- BytesMessage bm = (BytesMessage)cons.receive();
- assertNotNull(bm);
- }
- finally
- {
- if (c != null)
- {
- c.close();
- }
- }
-
- }
+ public void testForeignByteMessage() throws Exception
+ {
+ Connection c = null;
- public void testJMSMessageIDChanged() throws Exception
- {
- Connection c = null;
-
- try
- {
-
- c= cf.createConnection();
- Session s = c.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageProducer p = s.createProducer(queue1);
-
- Message m = new SimpleJMSMessage();
- m.setJMSMessageID("something");
-
- p.send(m);
-
- assertFalse("something".equals(m.getJMSMessageID()));
-
- c.close();
- }
- finally
- {
- if (c != null)
- {
- c.close();
- }
-
- removeAllMessages(queue1.getQueueName(), true, 0);
- }
- }
+ try
+ {
+ c = cf.createConnection();
+ Session s = c.createSession(false, Session.AUTO_ACKNOWLEDGE);
- /**
- * com.sun.ts.tests.jms.ee.all.queueconn.QueueConnTest line 171
- */
- public void test_1() throws Exception
- {
- QueueConnection qc = null;
-
- try
- {
- qc = cf.createQueueConnection();
- QueueSession qs = qc.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageProducer p = s.createProducer(queue1);
+
+ // create a Bytes foreign message
+ SimpleJMSBytesMessage bfm = new SimpleJMSBytesMessage();
+
+ p.send(bfm);
+
+ MessageConsumer cons = s.createConsumer(queue1);
+ c.start();
+
+ BytesMessage bm = (BytesMessage)cons.receive();
+ assertNotNull(bm);
+ }
+ finally
+ {
+ if (c != null)
+ {
+ c.close();
+ }
+ }
+
+ }
+
+ public void testJMSMessageIDChanged() throws Exception
+ {
+ Connection c = null;
+
+ try
+ {
+
+ c= cf.createConnection();
+ Session s = c.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageProducer p = s.createProducer(queue1);
+
+ Message m = new SimpleJMSMessage();
+ m.setJMSMessageID("something");
+
+ p.send(m);
+
+ assertFalse("something".equals(m.getJMSMessageID()));
+
+ c.close();
+ }
+ finally
+ {
+ if (c != null)
+ {
+ c.close();
+ }
+
+ removeAllMessages(queue1.getQueueName(), true, 0);
+ }
+ }
+
+ /**
+ * com.sun.ts.tests.jms.ee.all.queueconn.QueueConnTest line 171
+ */
+ public void test_1() throws Exception
+ {
+ QueueConnection qc = null;
+
+ try
+ {
+ qc = cf.createQueueConnection();
+ QueueSession qs = qc.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ QueueReceiver qreceiver = qs.createReceiver(queue1, "targetMessage = TRUE");
+
+ qc.start();
+
+ TextMessage m = qs.createTextMessage();
+ m.setText("one");
+ m.setBooleanProperty("targetMessage", false);
+
+ QueueSender qsender = qs.createSender(queue1);
+
+ qsender.send(m);
+
+ m.setText("two");
+ m.setBooleanProperty("targetMessage", true);
+
+ qsender.send(m);
+
+ TextMessage rm = (TextMessage)qreceiver.receive(1000);
+
+ assertEquals("two", rm.getText());
+ }
+ finally
+ {
+ if (qc != null)
+ {
+ qc.close();
+ }
+ Thread.sleep(2000);
+ log.info("****** removing merssages");
+ removeAllMessages(queue1.getQueueName(), true, 0);
+ checkEmpty(queue1);
+ }
+ }
+
+ public void testInvalidSelectorOnDurableSubscription() throws Exception
+ {
+ Connection c = null;
+
+ try
+ {
+ c = cf.createConnection();
+ c.setClientID("something");
+
+ Session s = c.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ try
+ {
+ s.createDurableSubscriber(topic1, "somename", "=TEST 'test'", false);
+ fail("this should fail");
+ }
+ catch(InvalidSelectorException e)
+ {
+ // OK
+ }
+ }
+ finally
+ {
+ c.close();
+ }
+ }
+
+ public void testInvalidSelectorOnSubscription() throws Exception
+ {
+ TopicConnection c = null;
+ try
+ {
+ c = cf.createTopicConnection();
+ c.setClientID("something");
+
+ TopicSession s = c.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ try
+ {
+ s.createSubscriber(topic1, "=TEST 'test'", false);
+ fail("this should fail");
+ }
+ catch(InvalidSelectorException e)
+ {
+ // OK
+ }
+ }
+ finally
+ {
+ c.close();
+ }
+ }
- QueueReceiver qreceiver = qs.createReceiver(queue1, "targetMessage = TRUE");
-
- qc.start();
-
- TextMessage m = qs.createTextMessage();
- m.setText("one");
- m.setBooleanProperty("targetMessage", false);
-
- QueueSender qsender = qs.createSender(queue1);
-
- qsender.send(m);
-
- m.setText("two");
- m.setBooleanProperty("targetMessage", true);
-
- qsender.send(m);
-
- TextMessage rm = (TextMessage)qreceiver.receive(1000);
-
- assertEquals("two", rm.getText());
- }
- finally
- {
- if (qc != null)
- {
- qc.close();
- }
- Thread.sleep(2000);
- log.info("****** removing merssages");
- removeAllMessages(queue1.getQueueName(), true, 0);
- checkEmpty(queue1);
- }
- }
+ /* By default we send non persistent messages asynchronously for performance reasons
+ * when running with strictTCK we send them synchronously
+ */
+ public void testNonPersistentMessagesSentSynchronously() throws Exception
+ {
+ Connection c = null;
- public void testInvalidSelectorOnDurableSubscription() throws Exception
- {
- Connection c = null;
-
- try
- {
- c = cf.createConnection();
- c.setClientID("something");
+ try
+ {
+ c= cf.createConnection();
+ Session s = c.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Session s = c.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageProducer p = s.createProducer(queue1);
+
+ p.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+
+ final int numMessages = 100;
+
+ this.assertRemainingMessages(0);
+
+ for (int i = 0; i < numMessages; i++)
+ {
+ p.send(s.createMessage());
+ }
+
+ this.assertRemainingMessages(numMessages);
+ }
+ finally
+ {
+ if (c != null)
+ {
+ c.close();
+ }
- try
- {
- s.createDurableSubscriber(topic1, "somename", "=TEST 'test'", false);
- fail("this should fail");
- }
- catch(InvalidSelectorException e)
- {
- // OK
- }
- }
- finally
- {
- c.close();
- }
- }
+ removeAllMessages(queue1.getQueueName(), true, 0);
+ }
+ }
- public void testInvalidSelectorOnSubscription() throws Exception
- {
- TopicConnection c = null;
- try
- {
- c = cf.createTopicConnection();
- c.setClientID("something");
-
- TopicSession s = c.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ ServerManagement.undeployConnectionFactory(new ObjectName(ORG_JBOSS_MESSAGING_SERVICE_LBCONNECTION_FACTORY));
+ }
- try
- {
- s.createSubscriber(topic1, "=TEST 'test'", false);
- fail("this should fail");
- }
- catch(InvalidSelectorException e)
- {
- // OK
- }
- }
- finally
- {
- c.close();
- }
- }
+ // Package protected ---------------------------------------------
- protected void tearDown() throws Exception
- {
- super.tearDown();
- ServerManagement.undeployConnectionFactory(new ObjectName(ORG_JBOSS_MESSAGING_SERVICE_LBCONNECTION_FACTORY));
- }
+ // Protected -----------------------------------------------------
- // Package protected ---------------------------------------------
+ // Private -------------------------------------------------------
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
+ // Inner classes -------------------------------------------------
}
More information about the jboss-cvs-commits
mailing list