Hello Camunda team.
I have a question about process variables. (Process Variables | docs.camunda.org)
Here we multiple supported variable values, such primitive types as complex java pojo objects.
I want to set Entity classes into variables but I don’t want to use java object serialization (byte array streams into database).
I remember somewhere in youtube videos was talk about JPA entity serialization (I cant find this video now) which means Camunda can save only ID value of an Entity Class not a full java object. And in process of deserialization Camunda will retrieve this Entity class from database using saved Entity ID.
Is there any example of documentation how to implement this kind of serialization ?
P.S.
We made debug of camunda serialization example. Camunda Version (7.9.0).
We tried to store our entity Class object into variables. For Example : EmergencyCase.
We know that this Class : “DefaultVariableSerializers” is used to store variables.
During the debug we step into the method : “findSerializerForValue”.
this method finds 2 type of serialization object with this criteria
“if(serializer.canHandle(value))”
1.JPAVariableSerializer
2.JavaObjectSerializer
Serializators are stored the same order as I described above into matchedSerializers list :
List<TypedValueSerializer<?>> matchedSerializers = new ArrayList<TypedValueSerializer<?>>();
Default Serializator data from in the configuration class “ProcessEngineConfigurationImpl” is
JAVA(“application/x-java-serialized-object”)
so the this part of code ignores JPAVariableSerializer.
// ambiguous match, use default serializer
if(defaultSerializationFormat != null) {
for (TypedValueSerializer<?> typedValueSerializer : matchedSerializers) {
if(defaultSerializationFormat.equals(typedValueSerializer.getSerializationDataformat())) {
return typedValueSerializer;
}
}
}
So we override default serialization data format from the configuration (Application.yml) :
camunda:
bpm:
history-level: full
default-serialization-format: application/json
This kind of configuration cause : Camunda now uses JPAVariableSerializer, as we wanted to.
Now we see data in the table (act_ru_variable) like this :
type_ = ‘jpa’ instead of ‘serializable’
bytearray_id_ is null instead of UUID of related table.
text_ = fully classified class name of an entity instead of null
text2_ = entity ID value instead of fully classified class name of an entity.
Is this the correct way to use JPAVariableSerializer ?
Regards,
Paata.