Title: [750] trunk/core/src/test/java/org/servicemix/jbi/messaging: Fix more transaction problems.
Revision
750
Author
gnt
Date
2005-11-04 11:36:52 -0500 (Fri, 04 Nov 2005)

Log Message

Fix more transaction problems.
All should be ok, by now.
Only remains https://jira.logicblaze.com/jira/browse/SM-145

Modified Paths

Diff

Modified: trunk/core/src/main/java/org/servicemix/jbi/messaging/DeliveryChannelImpl.java (749 => 750)

--- trunk/core/src/main/java/org/servicemix/jbi/messaging/DeliveryChannelImpl.java	2005-11-04 15:24:01 UTC (rev 749)
+++ trunk/core/src/main/java/org/servicemix/jbi/messaging/DeliveryChannelImpl.java	2005-11-04 16:36:52 UTC (rev 750)
@@ -348,9 +348,11 @@
             if (log.isDebugEnabled()) {
                 log.debug("Exception processing: " + messageExchange.getExchangeId() + " in " + this);
             }
+            throw e;
+        } finally {
             if (messageExchange.getTransactionContext() != null) {
-                suspendTx(messageExchange);
                 if (messageExchange.getMirror().getSyncState() == MessageExchangeImpl.SYNC_STATE_SYNC_SENT) {
+                    suspendTx(messageExchange);
                     if (log.isDebugEnabled()) {
                         log.debug("Notifying: " + messageExchange.getExchangeId() + " in " + this);
                     }
@@ -359,7 +361,6 @@
                     }
                 }
             }
-            throw e;
         }
         
         /*
@@ -634,6 +635,9 @@
             if (oldTx != null) {
                 TransactionManager tm = (TransactionManager) container.getTransactionManager();
     			if (tm != null) {
+                    if (log.isDebugEnabled()) {
+                        log.debug("Suspending transaction for " + me.getExchangeId() + " in " + this);
+                    }
     				Transaction tx = tm.suspend();
     				if (tx != oldTx) {
     					throw new IllegalStateException("the transaction context set in the messageExchange is not bound to the current thread");
@@ -651,6 +655,9 @@
             if (oldTx != null) {
                 TransactionManager tm = (TransactionManager) container.getTransactionManager();
     			if (tm != null) {
+                    if (log.isDebugEnabled()) {
+                        log.debug("Resuming transaction for " + me.getExchangeId() + " in " + this);
+                    }
     				tm.resume(oldTx);
     			}
             }

Modified: trunk/core/src/test/java/org/servicemix/jbi/messaging/AbstractPersistenceTest.java (749 => 750)

--- trunk/core/src/test/java/org/servicemix/jbi/messaging/AbstractPersistenceTest.java	2005-11-04 15:24:01 UTC (rev 749)
+++ trunk/core/src/test/java/org/servicemix/jbi/messaging/AbstractPersistenceTest.java	2005-11-04 16:36:52 UTC (rev 750)
@@ -48,14 +48,15 @@
         container.setName(name);
         container.setFlow(createFlow());
         container.setPersistent(true);
+        container.setMonitorInstallationDirectory(false);
         container.init();
         container.start();
         return container;
     }
     
     protected void runSimpleTest(final boolean syncSend, final boolean syncReceive) throws Exception {
-    	//final int numMessages = 1;
-    	final int numMessages = NUM_MESSAGES;
+        //final int numMessages = 1;
+        final int numMessages = NUM_MESSAGES;
         final SenderComponent sender = new SenderComponent();
         sender.setResolver(new ServiceNameEndpointResolver(ReceiverComponent.SERVICE));
         final Receiver receiver;

Modified: trunk/core/src/test/java/org/servicemix/jbi/messaging/AbstractTransactionTest.java (749 => 750)

--- trunk/core/src/test/java/org/servicemix/jbi/messaging/AbstractTransactionTest.java	2005-11-04 15:24:01 UTC (rev 749)
+++ trunk/core/src/test/java/org/servicemix/jbi/messaging/AbstractTransactionTest.java	2005-11-04 16:36:52 UTC (rev 750)
@@ -88,6 +88,7 @@
         container.setName(name);
         container.setFlow(createFlow());
         container.setAutoEnlistInTransaction(true);
+        container.setMonitorInstallationDirectory(false);
         container.init();
         container.start();
         return container;
@@ -122,7 +123,12 @@
     }
     
     public void testSyncSendSyncReceive() throws Exception {
-    	runSimpleTest(true, true);
+        try {
+            runSimpleTest(true, true);
+            fail("sendSync can not be used");
+        } catch (IllegalStateException e) {
+            // sendSync can not be used
+        }
     }
 
     public void testAsyncSendSyncReceive() throws Exception {
@@ -130,7 +136,12 @@
     }
 
     public void testSyncSendAsyncReceive() throws Exception {
-    	runSimpleTest(true, false);
+        try {
+            runSimpleTest(true, false);
+            fail("sendSync can not be used");
+        } catch (IllegalStateException e) {
+            // sendSync can not be used
+        }
     }
 
     public void testAsyncSendAsyncReceive() throws Exception {

Reply via email to