[jboss-cvs] JBoss Messaging SVN: r5567 - in trunk: src/main/org/jboss/messaging/core/transaction/impl and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Jan 2 07:34:41 EST 2009
Author: timfox
Date: 2009-01-02 07:34:41 -0500 (Fri, 02 Jan 2009)
New Revision: 5567
Modified:
trunk/src/main/org/jboss/messaging/core/server/impl/QueueImpl.java
trunk/src/main/org/jboss/messaging/core/transaction/impl/TransactionImpl.java
trunk/tests/src/org/jboss/messaging/tests/integration/DuplicateDetectionTest.java
Log:
Tweak on duplicat detection
Modified: trunk/src/main/org/jboss/messaging/core/server/impl/QueueImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/QueueImpl.java 2009-01-02 12:11:25 UTC (rev 5566)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/QueueImpl.java 2009-01-02 12:34:41 UTC (rev 5567)
@@ -160,7 +160,16 @@
if (cache.contains(duplicateID))
{
- log.warn("Duplicate message detected - message will not be routed");
+ if (tx == null)
+ {
+ log.warn("Duplicate message detected - message will not be routed");
+ }
+ else
+ {
+ log.warn("Duplicate message detected - transaction will be rejected");
+
+ tx.markAsRollbackOnly(null);
+ }
return;
}
Modified: trunk/src/main/org/jboss/messaging/core/transaction/impl/TransactionImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/transaction/impl/TransactionImpl.java 2009-01-02 12:11:25 UTC (rev 5566)
+++ trunk/src/main/org/jboss/messaging/core/transaction/impl/TransactionImpl.java 2009-01-02 12:34:41 UTC (rev 5567)
@@ -35,7 +35,6 @@
import org.jboss.messaging.core.settings.impl.QueueSettings;
import org.jboss.messaging.core.transaction.Transaction;
import org.jboss.messaging.core.transaction.TransactionOperation;
-import org.jboss.messaging.core.transaction.Transaction.State;
import org.jboss.messaging.util.SimpleString;
/**
@@ -281,8 +280,13 @@
{
synchronized (timeoutLock)
{
- if (state != State.ACTIVE)
+ if (state == State.ROLLBACK_ONLY)
{
+ //Do nothing
+ return;
+ }
+ else if (state != State.ACTIVE)
+ {
throw new IllegalStateException("Transaction is in invalid state " + state);
}
@@ -328,7 +332,8 @@
}
else
{
- throw new IllegalStateException("Transaction is in invalid state " + state);
+ //Do nothing
+ return;
}
}
@@ -431,8 +436,7 @@
{
operation.afterRollback();
}
- }
-
+ }
}
return toCancel;
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/DuplicateDetectionTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/DuplicateDetectionTest.java 2009-01-02 12:11:25 UTC (rev 5566)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/DuplicateDetectionTest.java 2009-01-02 12:34:41 UTC (rev 5567)
@@ -429,6 +429,67 @@
sf.close();
}
+ /*
+ * Entire transaction should be rejected on duplicate detection
+ * Even if not all entries have dupl id header
+ */
+ public void testEntireTransactionRejected() throws Exception
+ {
+ ClientSessionFactory sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"));
+
+ ClientSession session = sf.createSession(false, false, false);
+
+ session.start();
+
+ final SimpleString queueName = new SimpleString("DuplicateDetectionTestQueue");
+
+ session.createQueue(queueName, queueName, null, false, false);
+
+ ClientProducer producer = session.createProducer(queueName);
+
+ ClientMessage message = createMessage(session, 0);
+ SimpleString dupID = new SimpleString("abcdefg");
+ message.putStringProperty(MessageImpl.HDR_DUPLICATE_DETECTION_ID, dupID);
+ producer.send(message);
+
+ session.commit();
+
+ session.close();
+
+ session = sf.createSession(false, false, false);
+
+ session.start();
+
+ producer = session.createProducer(queueName);
+
+ message = createMessage(session, 1);
+ message.putStringProperty(MessageImpl.HDR_DUPLICATE_DETECTION_ID, dupID);
+ producer.send(message);
+
+ message = createMessage(session, 2);
+ producer.send(message);
+
+ message = createMessage(session, 3);
+ producer.send(message);
+
+ message = createMessage(session, 4);
+ producer.send(message);
+
+ session.commit();
+
+ ClientConsumer consumer = session.createConsumer(queueName);
+
+ message = consumer.receive(250);
+ assertEquals(0, message.getProperty(propKey));
+
+ message = consumer.receive(250);
+ assertNull(message);
+
+ session.close();
+
+ sf.close();
+ }
+
public void testXADuplicateDetection1() throws Exception
{
ClientSessionFactory sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"));
More information about the jboss-cvs-commits
mailing list