[jboss-svn-commits] JBL Code SVN: r24454 - in labs/jbossesb/trunk/product: rosetta/src/org/jboss/soa/esb/client and 1 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Sun Dec 21 03:38:12 EST 2008
Author: mark.little at jboss.com
Date: 2008-12-21 03:38:11 -0500 (Sun, 21 Dec 2008)
New Revision: 24454
Added:
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/message/IncompatibleTransactionScopeException.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/message/ResponseTimeoutException.java
Modified:
labs/jbossesb/trunk/product/docs/ProgrammersGuide.odt
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/client/ServiceInvoker.java
Log:
https://jira.jboss.org/jira/browse/JBESB-2049
Modified: labs/jbossesb/trunk/product/docs/ProgrammersGuide.odt
===================================================================
(Binary files differ)
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/client/ServiceInvoker.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/client/ServiceInvoker.java 2008-12-21 06:29:48 UTC (rev 24453)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/client/ServiceInvoker.java 2008-12-21 08:38:11 UTC (rev 24454)
@@ -24,7 +24,6 @@
import java.util.Date;
import java.util.List;
-import javax.crypto.SealedObject;
import javax.security.auth.Subject;
import org.apache.log4j.Logger;
@@ -40,9 +39,12 @@
import org.jboss.soa.esb.common.Configuration;
import org.jboss.soa.esb.common.Environment;
import org.jboss.soa.esb.common.ModulePropertyManager;
+import org.jboss.soa.esb.common.TransactionStrategy;
+import org.jboss.soa.esb.common.TransactionStrategyException;
import org.jboss.soa.esb.couriers.Courier;
import org.jboss.soa.esb.couriers.CourierException;
import org.jboss.soa.esb.couriers.CourierFactory;
+import org.jboss.soa.esb.couriers.CourierTimeoutException;
import org.jboss.soa.esb.couriers.CourierTransportException;
import org.jboss.soa.esb.couriers.CourierServiceBindException;
import org.jboss.soa.esb.couriers.CourierMarshalUnmarshalException;
@@ -53,7 +55,9 @@
import org.jboss.soa.esb.listeners.ha.LoadBalancePolicy;
import org.jboss.soa.esb.listeners.ha.ServiceClusterInfo;
import org.jboss.soa.esb.listeners.ha.ServiceClusterInfoImpl;
+import org.jboss.soa.esb.listeners.message.IncompatibleTransactionScopeException;
import org.jboss.soa.esb.listeners.message.MessageDeliverException;
+import org.jboss.soa.esb.listeners.message.ResponseTimeoutException;
import org.jboss.soa.esb.listeners.message.errors.Factory;
import org.jboss.soa.esb.message.Message;
import org.jboss.soa.esb.message.util.Type;
@@ -301,7 +305,7 @@
//removed EPRs that have now come back to life. We should try once more to pull a fresh list of EPRS
//from the registry before we give up (and fail-over to redelivery at a later time in the care
//of asyncDeliver). I think the end-user expects the message to be delivered successfully if there
- //is a healhty EPR out there. So this is really for EPR cache management (serviceClusterInfo will
+ //is a healthy EPR out there. So this is really for EPR cache management (serviceClusterInfo will
//be empty when going for the 2nd attempt, or else there delivery was successful and there will be
//no second attempt!).
while (staleEPRCache) {
@@ -571,6 +575,21 @@
message.getHeader().getCall().setTo(targetEPR);
if (synchronous) {
+ /*
+ * Currently all couriers that have transactional semantics work in a manner similar
+ * to JMS, i.e., messages are not delivered on to a queue (or to an endpoint) until
+ * the enclosing transaction has committed. In a synchronous invocation this will
+ * result in timeouts if the sending thread is also the terminating thread. We check
+ * for this here and throw an exception before we try to do a send so the application can
+ * figure it out.
+ *
+ * Note: if the transactional semantics change (e.g., to support true distributed transactions)
+ * then this will need to be modified too.
+ */
+
+ if (isTransactional())
+ throw new IncompatibleTransactionScopeException("Request-response attempt within running transaction controlling request delivery! Using epr [" + targetEPR + "] for Service [" + service + "] and Message ["+message.getHeader()+"]");
+
if (replyToEPR == null)
replyToEPR = getReplyToAddress(targetEPR);
@@ -618,6 +637,14 @@
logger.error("Unexpected error. Badly formed EPR [" + targetEPR + "] for Service [" + service + "]. But the EPR has already been validated!!");
throw e;
+ } catch (final CourierTimeoutException ex) {
+ logger.error("Response timeout using Courier for EPR [" + targetEPR + "] for Service [" + service + "] and Message ["+message.getHeader()+"].");
+
+ // timeout from synchronous invocation
+
+ // would like to make this an independent exception (not inherit from MDE). But signatures and applications would break.
+
+ throw new ResponseTimeoutException("Caught response timeout!", ex);
} catch (Throwable t) {
logger.error("Unexpected throwable during attempted message delivery using Courier for EPR [" + targetEPR + "] for Service [" + service + "] and Message ["+message.getHeader()+"].", t);
@@ -638,6 +665,37 @@
}
}
+ private boolean isTransactional() throws MessageDeliverException
+ {
+ boolean transactional;
+
+ try
+ {
+ TransactionStrategy txStrategy = TransactionStrategy.getTransactionStrategy(true);
+ Object txHandle = ((txStrategy == null) ? null : txStrategy.getTransaction());
+ boolean isActive = ((txStrategy == null) ? false : txStrategy.isActive());
+
+ transactional = (txHandle != null);
+
+ /*
+ * Make sure the current transaction is still active! If we
+ * have previously slept, then the timeout may be longer than that
+ * associated with the transaction.
+ */
+
+ if (transactional && !isActive)
+ {
+ throw new MessageDeliverException("Associated transaction is no longer active!");
+ }
+ }
+ catch (final TransactionStrategyException ex)
+ {
+ throw new MessageDeliverException("Could not determine transactionality.", ex);
+ }
+
+ return transactional;
+ }
+
static
{
String pruneDead = ModulePropertyManager.getPropertyManager(ModulePropertyManager.CORE_MODULE).getProperty(Environment.REMOVE_DEAD_EPR, "false");
Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/message/IncompatibleTransactionScopeException.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/message/IncompatibleTransactionScopeException.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/message/IncompatibleTransactionScopeException.java 2008-12-21 08:38:11 UTC (rev 24454)
@@ -0,0 +1,43 @@
+/*
+ * 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, JBoss Inc.
+ */
+package org.jboss.soa.esb.listeners.message;
+
+import org.jboss.soa.esb.BaseException;
+
+/**
+ * If a user attempts to use a request-response MEP while within the
+ * scope of a transaction then the request won't be sent until the transaction
+ * commits, which can't happen if the sender thread is blocked. Rather than wait for
+ * a timeout to occur we spot this incompatibility at send time and throw this
+ * exception. The application can then take appropriate action.
+ */
+
+public class IncompatibleTransactionScopeException extends BaseException {
+
+ private static final long serialVersionUID = 1L;
+
+ public IncompatibleTransactionScopeException(String message) {
+ super(message);
+ }
+
+ public IncompatibleTransactionScopeException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/message/ResponseTimeoutException.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/message/ResponseTimeoutException.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/message/ResponseTimeoutException.java 2008-12-21 08:38:11 UTC (rev 24454)
@@ -0,0 +1,37 @@
+/*
+ * 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, JBoss Inc.
+ */
+package org.jboss.soa.esb.listeners.message;
+
+/**
+ * Timeout on response.
+ */
+
+public class ResponseTimeoutException extends MessageDeliverException {
+
+ private static final long serialVersionUID = 1L;
+
+ public ResponseTimeoutException(String message) {
+ super(message);
+ }
+
+ public ResponseTimeoutException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
More information about the jboss-svn-commits
mailing list