You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by mr...@apache.org on 2007/01/16 20:03:31 UTC
svn commit: r496822 - in /incubator/ode/trunk:
axis2/src/main/java/org/apache/ode/axis2/
bpel-api/src/main/java/org/apache/ode/bpel/iapi/
bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/
bpel-scheduler-quartz/src/main/java/org/apache/ode/bpel/sc...
Author: mriou
Date: Tue Jan 16 11:03:30 2007
New Revision: 496822
URL: http://svn.apache.org/viewvc?view=rev&rev=496822
Log:
Under Geronimo executing a transaction in the afterCompletion leads to an exception as it doesn't consider the first transaction as finished. Added a method to execute a new transaction in a separate thread to isolate the two executions.
Modified:
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ExternalService.java
incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/Scheduler.java
incubator/ode/trunk/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/MockBpelServer.java
incubator/ode/trunk/bpel-scheduler-quartz/src/main/java/org/apache/ode/bpel/scheduler/quartz/QuartzSchedulerImpl.java
Modified: incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ExternalService.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ExternalService.java?view=diff&rev=496822&r1=496821&r2=496822
==============================================================================
--- incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ExternalService.java (original)
+++ incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ExternalService.java Tue Jan 16 11:03:30 2007
@@ -212,7 +212,7 @@
private void replyWithFailure(final PartnerRoleMessageExchange odeMex, final FailureType error, final String errmsg,final Element details) {
// ODE MEX needs to be invoked in a TX.
try {
- _sched.execTransaction(new Callable<Void>() {
+ _sched.execIsolatedTransaction(new Callable<Void>() {
public Void call() throws Exception {
odeMex.replyWithFailure(error, errmsg, details);
return null;
@@ -230,7 +230,7 @@
private void reply(final PartnerRoleMessageExchange odeMex, final OMElement reply) {
// ODE MEX needs to be invoked in a TX.
try {
- _sched.execTransaction(new Callable<Void>() {
+ _sched.execIsolatedTransaction(new Callable<Void>() {
public Void call() throws Exception {
Message response = odeMex.createMessage(odeMex.getOperation().getOutput().getMessage().getQName());
try {
Modified: incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/Scheduler.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/Scheduler.java?view=diff&rev=496822&r1=496821&r2=496822
==============================================================================
--- incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/Scheduler.java (original)
+++ incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/Scheduler.java Tue Jan 16 11:03:30 2007
@@ -28,75 +28,86 @@
*/
public interface Scheduler {
- /**
- * Schedule a persisted job. Persisted jobs MUST survive system failure.
- * They also must not be scheduled unless the transaction associated with
- * the calling thread commits.
- * @param jobDetail information about the job
- * @param when when the job should run (<code>null</code> means now)
- * @return unique job identifier
- */
- String schedulePersistedJob(Map<String,Object>jobDetail,Date when)
- throws ContextException ;
-
-
- /**
- * Schedule a volatile (non-persisted) job. Volatile jobs should not be
- * saved in the database and should not survive system crash. Volatile
- * jobs scheduled from a transactional context should be scheduled
- * regardless of whether the tansaction commits.
- *
- * @param jobDetail information about the job
- * @param when when the job should run (<code>null</code> means now)
- * @return unique (as far as the scheduler is concerned) job identifier
- */
- String scheduleVolatileJob(boolean transacted, Map<String,Object> jobDetail,
- Date when) throws ContextException;
-
- /**
- * Make a good effort to cancel the job. If its already running no big
- * deal.
- * @param jobId job identifier of the job
- */
- void cancelJob(String jobId) throws ContextException;
-
- /**
- * Execute a {@link Callable} in a transactional context. If the callable
- * throws an exception, then the transaction will be rolled back, otherwise
- * the transaction will commit.
- *
- * @param <T> return type
- * @param transaction transaction to execute
- * @return result
- * @throws Exception
- */
- <T> T execTransaction(Callable<T> transaction)
- throws Exception, ContextException;
-
- /**
- * Register a transaction synchronizer.
- * @param synch synchronizer
- * @throws ContextException
- */
- void registerSynchronizer(Synchronizer synch) throws ContextException;
-
- void start();
-
- void stop();
-
- void shutdown();
-
- public interface Synchronizer {
- /**
- * Called after the transaction is completed.
- * @param success indicates whether the transaction was comitted
- */
- void afterCompletion(boolean success);
-
- /**
- * Called before the transaction is completed.
- */
- void beforeCompletion();
+ /**
+ * Schedule a persisted job. Persisted jobs MUST survive system failure.
+ * They also must not be scheduled unless the transaction associated with
+ * the calling thread commits.
+ * @param jobDetail information about the job
+ * @param when when the job should run (<code>null</code> means now)
+ * @return unique job identifier
+ */
+ String schedulePersistedJob(Map<String,Object>jobDetail,Date when)
+ throws ContextException ;
- }
+
+ /**
+ * Schedule a volatile (non-persisted) job. Volatile jobs should not be
+ * saved in the database and should not survive system crash. Volatile
+ * jobs scheduled from a transactional context should be scheduled
+ * regardless of whether the tansaction commits.
+ *
+ * @param jobDetail information about the job
+ * @param when when the job should run (<code>null</code> means now)
+ * @return unique (as far as the scheduler is concerned) job identifier
+ */
+ String scheduleVolatileJob(boolean transacted, Map<String,Object> jobDetail,
+ Date when) throws ContextException;
+
+ /**
+ * Make a good effort to cancel the job. If its already running no big
+ * deal.
+ * @param jobId job identifier of the job
+ */
+ void cancelJob(String jobId) throws ContextException;
+
+ /**
+ * Execute a {@link Callable} in a transactional context. If the callable
+ * throws an exception, then the transaction will be rolled back, otherwise
+ * the transaction will commit.
+ *
+ * @param <T> return type
+ * @param transaction transaction to execute
+ * @return result
+ * @throws Exception
+ */
+ <T> T execTransaction(Callable<T> transaction)
+ throws Exception, ContextException;
+
+ /**
+ * Same as execTransaction but executes in a different thread to guarantee
+ * isolation from the main execution thread.
+ * @param transaction
+ * @return
+ * @throws Exception
+ * @throws ContextException
+ */
+ <T> T execIsolatedTransaction(final Callable<T> transaction)
+ throws Exception, ContextException;
+
+ /**
+ * Register a transaction synchronizer.
+ * @param synch synchronizer
+ * @throws ContextException
+ */
+ void registerSynchronizer(Synchronizer synch) throws ContextException;
+
+ void start();
+
+ void stop();
+
+ void shutdown();
+
+ public interface Synchronizer {
+ /**
+ * Called after the transaction is completed.
+ * @param success indicates whether the transaction was comitted
+ */
+ void afterCompletion(boolean success);
+
+ /**
+ * Called before the transaction is completed.
+ */
+ void beforeCompletion();
+
+ }
}
Modified: incubator/ode/trunk/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/MockBpelServer.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/MockBpelServer.java?view=diff&rev=496822&r1=496821&r2=496822
==============================================================================
--- incubator/ode/trunk/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/MockBpelServer.java (original)
+++ incubator/ode/trunk/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/MockBpelServer.java Tue Jan 16 11:03:30 2007
@@ -308,6 +308,9 @@
public <T> T execTransaction(Callable<T> transaction) throws Exception, ContextException {
return _quartz.execTransaction(transaction);
}
+ public <T> T execIsolatedTransaction(Callable<T> transaction) throws Exception, ContextException {
+ return _quartz.execIsolatedTransaction(transaction);
+ }
public void start() { _quartz.start(); }
public void stop() { _quartz.stop(); }
Modified: incubator/ode/trunk/bpel-scheduler-quartz/src/main/java/org/apache/ode/bpel/scheduler/quartz/QuartzSchedulerImpl.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-scheduler-quartz/src/main/java/org/apache/ode/bpel/scheduler/quartz/QuartzSchedulerImpl.java?view=diff&rev=496822&r1=496821&r2=496822
==============================================================================
--- incubator/ode/trunk/bpel-scheduler-quartz/src/main/java/org/apache/ode/bpel/scheduler/quartz/QuartzSchedulerImpl.java (original)
+++ incubator/ode/trunk/bpel-scheduler-quartz/src/main/java/org/apache/ode/bpel/scheduler/quartz/QuartzSchedulerImpl.java Tue Jan 16 11:03:30 2007
@@ -26,6 +26,7 @@
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Future;
import javax.sql.DataSource;
import javax.transaction.Status;
@@ -262,6 +263,16 @@
}
}
}
+
+ public <T> T execIsolatedTransaction(final Callable<T> transaction) throws Exception, ContextException {
+ Future<T> res = _executorSvc.submit(new Callable<T>() {
+ public T call() throws Exception {
+ return execTransaction(transaction);
+ }
+ });
+ return res.get();
+ }
+
protected void rollback() throws Exception {
try {