cancel
Showing results for 
Search instead for 
Did you mean: 

Java Service Task: Passivate w/out Receive Task

jjfutt
Champ in-the-making
Champ in-the-making
Attached above is an illustration of a problem we are trying to solve. We have tasks that are implemented as 'Java Service Tasks'. However, these tasks are long running asynchronous tasks that invoke a request to do something (for example send a message to a JMS queue), but then have to wait for an asynchronous response. Currently, we achieve this by placing a 'Receive' task immediately following the Java Service Task which causes the Activiti process to pause and passivate. Then, when a JMS message is received, our external application layer resumes the process by signaling the Process Engine with the id of the Receive Task. However, this is complicated because (a ) we have to send the id of the receive task to our Java Task so it can be used for correlation and used in signaling the process (b ) Visually it forces us to break up the process into two nodes, a Java Invoke and a Receive.

We have moved to Activiti from JBPM and JBPM provides a 'Domain Specific Task' similar to Java Service Task. However, unlike the Activiti Delegate in Java Service Task, their Domain Specific Task allows us to exit out of the delegate method, without calling it the node as 'complete'. This way the engine knows that the method execution is complete, but the it's not okay to proceed forward yet. Until an external application signals the process to resume. However, in the case of JBPM, we can signal with the id of the original Java Task and that eliminates the need to have an extra 'Receive' like task, and also doesn't require the Java Task to know about the id of another node from the process.

I know that there have been recent improvements and enhancements in the engine, but reading the documentation, it doesn't seem that there is any new capability that would solve our problems. So I'd like your advice on:

(i) whether there is a way to complete the Java User Task delegate method, but prevent the engine from proceeding forward until an external process tells it to move on?

(ii) Another way to describe the same need: We want to passivate the Activiti process while waiting for the asynchronous response because otherwise the Java Method might timeout, and also because without a passivation the process will continue to occupy a thread of execution. So we are essentially looking for a way to passivate/pause after the invocation of Java call, until an asynchronous response is received.

Thanks in advance.

NOTE: The process shown in the attached diagram is a very simplified version created solely for the purpose of illustrating this question. Hence the long descriptive names for the process nodes.
11 REPLIES 11

jbarrez
Star Contributor
Star Contributor
No, you shouldn't, that case is only needed when you are working with compensation events

dgiormov
Champ in-the-making
Champ in-the-making
Is it possible if we want to "fail" the task from within the signal method, so it can retry latter? Or should we do it from the signal caller?

Dimitar