On Mon, Apr 27, 2009 at 7:03 AM, <[email protected]> wrote:

> Hi,
>
> I posted message below some time ago, but there was no response (or did I
> miss it?
> I didn't find anything in the archives, either).
>
> Any idea about it? Tammo?
>
> Thanks in advance for any hint you can give me.
>
> Regards,
> Juergen.
>
>
> -----Original Message-----
> From: [email protected] [mailto:
> [email protected]]
> Sent: Tuesday, April 14, 2009 3:15 PM
> To: [email protected]
> Subject: Concurrent execution of extension activities (RE: Problem with
> flow and extension activities)
>
> Hi Tammo,
>
> > -----Original Message-----
> > From: Tammo van Lessen [mailto:[email protected]]
> > Sent: Thursday, April 02, 2009 4:17 PM
> > Subject: Re: AW: Problem with flow and extension activities
> >
> > That's true. If you need a concurrent execution of extension activities
> > you'd need to implement the abstract class for async extensions, fork
> > your own thread and call the ExtensionContext.complete method once your
> > processing has finished. In this case the run method can finish before
> > the processing is done and the navigation continues.
>
> I tried this with ODE 2.0 beta2 and put the complete code of my extension
> activity
> execution in a Runnable to be executed in an own thread, but it doesn't
> work yet.
> The code is basically like this:
>
> class MyExtensionActivity extends AbstractAsyncExtensionOperation {
>
>  static java.util.concurrent.Executor executor =
> Executors.newCachedThreadPool();
>
>  void run(...) {
>    executor.execute(new Runnable() {
>      public void run() {
>          // extension activity code:
>        // read variables from ext context
>        // do something
>          // write variables to ext context
>          // complete ext context
>      }
>    }
>  }
> }
>
> For in-memory=true there is an exception when I try to complete the
> ExtensionContext:
>
> java.lang.NullPointerException
>        at
> org.apache.ode.jacob.vpu.JacobVPU.activeJacobThread(JacobVPU.java:203)
>        at
> org.apache.ode.jacob.vpu.ChannelFactory$ChannelInvocationHandler.invoke(ChannelFactory.java:89)
>        at $Proxy42.completed(Unknown Source)
>        at
> org.apache.ode.bpel.rtrep.v2.ExtensionContextImpl.complete(ExtensionContextImpl.java:147)
>
> So the actual execution of the extension code has worked in this case.
>
> For in-memory=false I get an exception when trying to read a variable in my
> separate thread:
>
> java.lang.NullPointerException
>        at
> org.apache.ode.dao.jpa.ProcessInstanceDAOImpl.getScope(ProcessInstanceDAOImpl.java:231)
>        at
> org.apache.ode.bpel.engine.BpelRuntimeContextImpl.fetchVariableData(BpelRuntimeContextImpl.java:354)
>        at
> org.apache.ode.bpel.rtrep.v2.RuntimeInstanceImpl.fetchVariableData(RuntimeInstanceImpl.java:155)
>        at
> org.apache.ode.bpel.rtrep.v2.ExtensionContextImpl.readVariable(ExtensionContextImpl.java:90)
>        at
> org.apache.ode.bpel.rtrep.v2.ExtensionContextImpl.readVariable(ExtensionContextImpl.java:108)
>
> which means that the DAO impl cannot find it's associated JPA entity
> manager anymore.
> So it seems I cannot access the variables in the extension context in this
> case.
>
> And then there's another exception on completeWithFault() that looks
> similar to the above:
>
> Exception in thread "pool-2-thread-3" java.lang.NullPointerException
>        at
> org.apache.ode.jacob.vpu.JacobVPU.activeJacobThread(JacobVPU.java:203)
>        at
> org.apache.ode.jacob.vpu.ChannelFactory$ChannelInvocationHandler.invoke(ChannelFactory.java:89)
>        at $Proxy40.completed(Unknown Source)
>        at
> org.apache.ode.bpel.rtrep.v2.ExtensionContextImpl.completeWithFault(ExtensionContextImpl.java:162)
>
> It doesn't matter if my extension activities are actually called from
> within a <flow> or not.
> It also didn't change anything to let my extension implementation extend
> AbstractAsyncExtensionOperation
> instead of just implementing ExtensionOperation (I also did not find
> anything in the ODE code, where they
> are treated differently). Or have there been changes since 2.0-beta2 that
> make this work?
>
> Or is there just something I am missing or that I have misunderstood? (-;
>

You can't start a thread that will do something at the Jacob level. When you
think of it, the main purpose of Jacob is to avoid multi-threading by using
a cooperative and lightweight threading model. The way you do parrallel
stuff in Jacob is by injecting more threads.

So I guess the question becomes: what do you need a thread for in your
extension?

Matthieu


> Thanks for your patience,
> Juergen.
>
>

Reply via email to