cancel
Showing results for 
Search instead for 
Did you mean: 

For service task return values, is Serializable required?

matt1
Champ in-the-making
Champ in-the-making
I'm new to Activiti so please bear with me.

I was playing around with returning values from service tasks and then passing that value to the subsequent task, and I was only able to return a POJO and use it in the subsequent task if I implemented Serializable. (maybe I'm doing something wrong.)

So this worked
public class Claim implements Serializable {
    long claimId;
    DateTime created;



But this causes some type of serialization exception:
public class Claim {
    long claimId;
    DateTime created;



More specifically I was using return value from task1 and passing it as an argument to task2, in both cases using Expressions.

task1 expression
#{prepareClaim()}
(return value set to 'claim')

task 2 expression
${claimService.create(claim)}


If Serializable is required, my question would then be why?

BTW, still not sure when to use
$
vs
#















3 REPLIES 3

jbarrez
Star Contributor
Star Contributor
If you do it like that, the values will be serialized to the database as java pojos. So yes, in that case these classes must be Serializable.

matt1
Champ in-the-making
Champ in-the-making
>If you do it like that
Is there another way? What is the best practice?

trademak
Star Contributor
Star Contributor
If you need the values in another task, you need to set multiple primitive values or you can serialize the full value as a Java object or change it JSON or XML.

Best regards,