[jboss-svn-commits] JBL Code SVN: r20142 - in labs/jbossesb/trunk/product/samples/quickstarts/jms_transacted: src/org/jboss/soa/esb/samples/quickstart/jmstransacted/test and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri May 23 12:30:32 EDT 2008
Author: kevin.conner at jboss.com
Date: 2008-05-23 12:30:32 -0400 (Fri, 23 May 2008)
New Revision: 20142
Added:
labs/jbossesb/trunk/product/samples/quickstarts/jms_transacted/src/org/jboss/soa/esb/samples/quickstart/jmstransacted/test/ThrowExceptionAction.java
Modified:
labs/jbossesb/trunk/product/samples/quickstarts/jms_transacted/build.xml
labs/jbossesb/trunk/product/samples/quickstarts/jms_transacted/jboss-esb.xml
Log:
revert back to throwing the exception: JBESB-1766
Modified: labs/jbossesb/trunk/product/samples/quickstarts/jms_transacted/build.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/jms_transacted/build.xml 2008-05-23 16:28:47 UTC (rev 20141)
+++ labs/jbossesb/trunk/product/samples/quickstarts/jms_transacted/build.xml 2008-05-23 16:30:32 UTC (rev 20142)
@@ -17,7 +17,7 @@
<arg value="Hello Transacted JMS World]"/>
<classpath refid="exec-classpath"/>
</java>
- <sleep milliseconds="4000"/>
+ <sleep milliseconds="10000"/>
<antcall target="select"/>
<antcall target="truncate"/>
</target>
Modified: labs/jbossesb/trunk/product/samples/quickstarts/jms_transacted/jboss-esb.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/jms_transacted/jboss-esb.xml 2008-05-23 16:28:47 UTC (rev 20141)
+++ labs/jbossesb/trunk/product/samples/quickstarts/jms_transacted/jboss-esb.xml 2008-05-23 16:30:32 UTC (rev 20142)
@@ -54,10 +54,12 @@
<property name="db-insert-sql" value="insert into jms_transacted_table(data_column) values(?)"/>
</action>
- <!-- Rollback the current transaction -->
- <action name="rollbackTransaction" class="org.jboss.soa.esb.samples.quickstart.jmstransacted.test.RollbackTransactionAction">
- <property name="rollback" value="true"/> <!-- optional as default is true -->
- <property name="nr-of-rollbacks" value="5"/> <!-- should match dLQMaxResent -->
+ <!--
+ Will throw an Exception for the configured number of rollbacks. This should trigger the transaction to be
+ rolledback and the message placed back onto the JMS queue.
+ -->
+ <action name="throwExceptionAction" class="org.jboss.soa.esb.samples.quickstart.jmstransacted.test.ThrowExceptionAction">
+ <property name="rollbacks" value="5"/> <!-- if greater than dLQMaxResent then message goes to the JMS DLQ -->
</action>
<action name="printMessageDone" class="org.jboss.soa.esb.actions.SystemPrintln">
Copied: labs/jbossesb/trunk/product/samples/quickstarts/jms_transacted/src/org/jboss/soa/esb/samples/quickstart/jmstransacted/test/ThrowExceptionAction.java (from rev 18707, labs/jbossesb/trunk/product/samples/quickstarts/jms_transacted/src/org/jboss/soa/esb/samples/quickstart/jmstransacted/test/ThrowExceptionAction.java)
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/jms_transacted/src/org/jboss/soa/esb/samples/quickstart/jmstransacted/test/ThrowExceptionAction.java (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/jms_transacted/src/org/jboss/soa/esb/samples/quickstart/jmstransacted/test/ThrowExceptionAction.java 2008-05-23 16:30:32 UTC (rev 20142)
@@ -0,0 +1,89 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+package org.jboss.soa.esb.samples.quickstart.jmstransacted.test;
+
+import static org.jboss.soa.esb.notification.jms.JMSPropertiesSetter.JMS_REDELIVERED;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.actions.ActionLifecycle;
+import org.jboss.soa.esb.actions.ActionLifecycleException;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.message.Message;
+
+/**
+ * ThrowExceptionAction is a simple action that throws an exception until
+ * the maximum rollback count has been
+ * if the message has not been redelivered (first call to this action).
+ * </p>
+ * Note that this class in only intended to be used with the
+ * jms_transacted quickstart.
+ * </p>
+ * @author <a href="mailto:daniel.bevenius at gmail.com">Daniel Bevenius</a>
+ *
+ */
+public class ThrowExceptionAction implements ActionLifecycle
+{
+ private Logger log = Logger .getLogger( ThrowExceptionAction.class );
+
+ /**
+ * Number of times we should rollback. This is just used so that we
+ * can specify when the action should proceed without rolling back the transaction
+ */
+ private int maxRollbacks;
+
+ /**
+ * Simple counter
+ */
+ private static int rollbackCounter;
+
+ public ThrowExceptionAction( final ConfigTree config )
+ {
+ maxRollbacks = Integer.parseInt( config.getAttribute( "rollbacks", "3") );
+ }
+
+ /**
+ * Will rollback the the current transaction until the rollbackCounter
+ * is less than the configured amount.
+ *
+ * @param message - ESB Message object
+ * @return Message - unchanged ESB Message Object
+ */
+ public Message process( final Message message )
+ {
+ log.debug( "rollbackCounter [" + rollbackCounter + "], nr-of-rollbacks [" + maxRollbacks + "]");
+ rollbackCounter++;
+ if ( rollbackCounter <= maxRollbacks )
+ {
+ throw new IllegalStateException( "[Throwing Exception to trigger a transaction rollback]");
+ }
+ else
+ {
+ rollbackCounter = 0;
+ }
+
+ return message;
+ }
+
+ public void processException(final Message message, final Throwable th) { }
+ public void destroy() throws ActionLifecycleException {}
+ public void initialise() throws ActionLifecycleException {}
+
+}
More information about the jboss-svn-commits
mailing list