cancel
Showing results for 
Search instead for 
Did you mean: 

Question about Transactions

bkwf2
Champ in-the-making
Champ in-the-making
Hi,

I am using a "Receive task" to wait for an external JVM process to complete. Once the external JVM process completes,
the external process will "signal" the wait task to proceed forward. The external process remotely talks to the Activiti WF engine. The external process has code like this:

   

getRuntimeService().setVariable(processId, "someVar", "someValue");
   
   // some more business logic takes place here.
   
   getRuntimeService().signal(executionId);

Now in the above scenario, if something goes wrong in the business logic, after the process variable is set, an exception is thrown, and "signal" is never sent. But I still
see the process variable persisted to the "ACT_RU_VARIABLE". Is there a way to elegantly rollback data changes thru a "transaction" as part of Activiti code..? Or do we need to provide our own transactions in this scenario?

To avoid the above issue, I tried to send signal like this:

   

getRuntimeService().signal(executionId, variables);

So instead of setting variables using "getRuntimeService().setVariable" before the signal is sent, I want to achieve the setting of process variables as part of the
signalling. But somehow the variables are never set in the Process scope. Am I doing something wrong..?

thx for any advice.

Bhushan
2 REPLIES 2

trademak
Star Contributor
Star Contributor
Hi,

You say you talk remotely to the Activiti engine. Are you using the REST API?
When you talk remotely to the Activiti Engine it's not possible to use one transaction for all the logic.
When you would use an embedded Activiti Engine it is possible by wrapping all the logic in one transaction and use the same transaction manager in the Activiti Engine.

Best regards,

bkwf2
Champ in-the-making
Champ in-the-making
Hi trademak,

Thanks for the reply.

I am not using REST API. I am using spring "remoting" for remote communication between client and Activiti server.

But if I use this:

getRuntimeService().signal(executionId, variables);
in my external JVM process, will this help..? I looked at the code of the above call and the code first sets the process variables and then sends the signal. And why is that when I use the above call and dump the "Process" vars in my "Receive Task" "End" callback method, I do not see the variables set…?

Another question. Does your new book "Activiti In Action" cover the topic of transactions and in general dealing with the above types of scenarios…? I was thinking of buying the MEAP for the book.

thx for the help.

Bhushan.