Storing process variables: Json (Spin) vs. String / what are the impacts?

If you want to try the KV store example, i just uploaded a small sample of the the Redis example i mentioned:

Run docker-compose up --build

it will run camunda 7.8 + latest redis with a shared network.

run docker-compose down -v when finished.

Where the myRedisValue was pulled from the redis db.

Send to Redis:

var Jedis = Java.type('redis.clients.jedis.Jedis')
var jedis = new Jedis("redisdb")
jedis.set("foo", "bar")

get from redis:

var Jedis = Java.type('redis.clients.jedis.Jedis')
var jedis = new Jedis("redisdb")
var value = jedis.get("foo");
execution.setVariable('myRedisValue', value)

see the JS and BPMN for the specific context: https://github.com/DigitalState/camunda-variations/tree/master/jdis-redis/bpmn

edit: and as with pending updates to jedis for redis module command support, it will mean very easy management of reJson support (http://rejson.io / RedisJSON - Use Redis as a JSON Store | Redis)

And you can use Redis namespaces or multiple-databases in the single Redis Server Instance to support variable storage isolation between process instances


The idea being:

You could easily run these scripts as Input/Output mappings on a task and push and pull data from something like redis with very little code.

2 Likes