Uhhmmmm first suggestion would be to read some docs, look at some examples, blogs etc...
Let me try to explain myself better. I did read the User guide for version 4.0, the developer guide had some outdated API but i've read that as well.
Let's say, when i reach a certain node, I call an asynchronous job. When this job is complete, it will call a callback method, say callbackAtoB(). From within this callback method, I need to signal so that execution can proceed to the next state.
I attempted to solve it using an eventListener A which is triggered when state A is entered. For simplicity's sake, I keep the processEngine in a static field. I instantiate the process. Now when callbackAtoB() is called, I use the executionId given in the eventListener in an attempt to singal. However, I get that org.jbpm.api.JbpmException: execution Process.1 does not exist.
So I was wondering if there is another way of doing it, or is there a simple thing i missing.
thanx in advance :)
I think you are missing some simple thing, but from just reading text I'm not going to guess etc. Can you make a simple unit test that demonstrates what you try to achieve. This should be possible from what I read (the async stuff can be emulated I think within the unit test)
Let's say this is the workflow:
<process name="phoneCheckProcess" key="PCP" xmlns="http://jbpm.org/4.0/jpdl"> <start g="72,187,48,48" name="start"> <transition to="phoneCheck"/> </start> <state continue="async" g="211,178,92,52" name="phoneCheck"> <on event="start"> <event-listener class="eventListener.MyEventListener"/> </on> <transition to="proceed"/> </state> <state g="390,181,92,52" name="proceed"> <transition to="end"/> </state> <end g="601,186,48,48" name="end" state="finished"/> </process>
When execution reaches MyEventListener, I call a web-service that is asynchronous (for testing purposes i use a mock). When that function completes, it calls a callbackHandler.
I have a class that keeps a static processEngine so that I can access it from my test case and callback handler.
In my test case;
ProcessInstance processInstance = MyController.getInstance().getExecutionService().startProcessInstanceByKey("PCP"); Execution executionInQuery = processInstance.findActiveExecutionIn("phoneCheck"); assertNotNull("Supposed to be <phoneCheck>", executionInQuery);
Here, things go like this. The web-service is called, and it calls the calbackHandler. The callback handler, accesses the static Process engine and does the following:
ProcessInstance instance = getInstance().getExecutionService().signalExecutionById(executionId);
where execution id is retrieved from the eventListener.
Now this gives me the exception that the executionId does not exist. I cannot figure this out. I have been trying various things here, but it still doesn't work. Any help or ideas would be greatly appreciated.
Extra info, if i try to signal using the same execution ID from within junit test case, it works. But then, my purpose is lost.
I'm surprised it works in your unit test and not with a webservice. You most likely do two different things then. From the words and some of your code I still see/read nothing that makes it impossible. Probably something to do with transaction demarcation so in the unittest case the instance is save to the database and in the other it isn't.
Yea, I also suspect transaction problems, will try using JTA transaction on JNDI binded Process Engine.
try to reload the execution instance before you signal it.
ProcessInstance execution = executionService.findProcessInstanceById(executionId); execution.signalExecutionById(executionId);
I did try reloading the execution, but it didn't help. It has something to do with transactions I figure.
I attempted doing the whole thing using JNDI with a web applications. That works wonderfully. So it is the testing environment that I can't quite figure out. We will see.
Thanks guys for all your input :)