How to configure custom serializer for java object value serialization - Camunda 7.4-alpha 1

3,915 views
Skip to first unread message

natu.v...@gmail.com

unread,
Sep 24, 2015, 3:22:27 AM9/24/15
to camunda BPM users
Hi,
My requirement is to have custom serialization strategy for the complex process variables because it is not always feasible to use java serialization. Also XML and JSON serialization can not be used since the process variable is a domain model object and needs a proper serialization in RDBMS. I was trying to use the latest Camunda 7.4.0-alpha1 and configure the custom Java Object Value serializer as specified in http://docs.camunda.org/manual/latest/user-guide/process-engine/variables/ (Object Value Serialization section), but I am not sure how to provide/configure the Custom Serializer to Camunda engine.
When I execute the process I get and exception

org.camunda.bpm.engine.ProcessEngineException: Cannot find serializer for value 'ObjectValue [value=org.camunda.bpm.unittest.CustomerData@2ab9a94, isDeserialized=true, serializationDataFormat=application/x-java-serialized-object, objectTypeName=null, serializedValue=null]'.

I understood from the documentation that we can specify the XML and JSON serialization for Camunda Spin but not sure how to specify Java Object Value serializer.


Thanks
Vaibhav

thorben....@camunda.com

unread,
Sep 24, 2015, 3:59:20 AM9/24/15
to camunda BPM users, natu.v...@gmail.com
Hi Vaibhav,

You can register a custom serializer by implementing the interface TypedValueSerializer and set a list of custom serializers on the engine property "customPreVariableSerializers" before building the process engine, for example in a process engine plugin. You can also have a look at the spin process engine plugin [1] that registers the Spin serializer and also shows how to find the default java object serializer in the list of serializers. The general procedure of finding a serializer for a variable is:

1. Iterate list of serializers from lowest rank to highest rank
2. Pick first serializer that is able to serialize object (canHandle(TypedValue) returns true)

So you could either remove the default Java object serializer from the list or make sure your serialier has a lower-ranked position.

Cheers,
Thorben

[1] https://github.com/camunda/camunda-bpm-platform/blob/master/engine-plugins/spin-plugin/src/main/java/org/camunda/spin/plugin/impl/SpinProcessEnginePlugin.java#L59-L64

natu.v...@gmail.com

unread,
Sep 24, 2015, 7:24:06 AM9/24/15
to camunda BPM users, natu.v...@gmail.com
Thanks a lot Thorben. I will give it a try.

Thanks
Vaibhav
Reply all
Reply to author
Forward
0 new messages