# More complex event registry payload description

**URL:** <https://forum.flowable.org/t/more-complex-event-registry-payload-description/6872>\
**Category:** Flowable Engine\
**Created:** [October 5, 2020, 10:39pm UTC](https://forum.flowable.org/t/more-complex-event-registry-payload-description/6872 "2020-10-05T22:39:05Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![akakunin](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/akakunin/32/1302_2.png) [@akakunin](https://forum.flowable.org/u/akakunin)\
**Post date:** [October 5, 2020, 10:39pm UTC](https://forum.flowable.org/t/more-complex-event-registry-payload-description/6872/1 "2020-10-05T22:39:05Z")

</div>

Hi! I’m experimenting with event registry introduced in 6.5.0.  
Everything so far for the moment - I can connect flowable with Kafka and initiate process then new event posted into Kafka.

But I have question - all samples I found has quite simple event payload - suitable for “flat” event data.

Lets imagine I have more complex event - there some variables - are JSON object itself. For example:

{“var1”:{“var2”:“value2”, “var3”:“value3”}}

How can I define event payload, so, whole var1 placed into process context? or, for example, only var2 placed into process context as String?

---

<div class="post-metadata">

**Author:** ![iadded](https://avatars.discourse-cdn.com/v4/letter/i/9dc877/32.png) [@iadded](https://forum.flowable.org/u/iadded)\
**Post date:** [October 27, 2020, 1:56pm UTC](https://forum.flowable.org/t/more-complex-event-registry-payload-description/6872/2 "2020-10-27T13:56:28Z")

</div>

Hi

I’m trying to manage complex payloads as well.  
Did you make any progress with this ?

Thanks  
Inbal

---

<div class="post-metadata">

**Author:** ![akakunin](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/akakunin/32/1302_2.png) [@akakunin](https://forum.flowable.org/u/akakunin)\
**Post date:** [October 27, 2020, 7:04pm UTC](https://forum.flowable.org/t/more-complex-event-registry-payload-description/6872/3 "2020-10-27T19:04:52Z")

</div>

Hi Inbal!  
Unfortunately no - did not resolved it yet

---

<div class="post-metadata">

**Author:** ![joram](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/joram/32/26_2.png) [@joram](https://forum.flowable.org/u/joram)\
**Post date:** [October 28, 2020, 8:44pm UTC](https://forum.flowable.org/t/more-complex-event-registry-payload-description/6872/4 "2020-10-28T20:44:31Z")

</div>

Indeed - currently complex mappings can be done by plugging in custom pipeline components, e.g. [https://github.com/flowable/flowable-engine/blob/master/modules/flowable-event-registry/src/test/java/org/flowable/eventregistry/test/CustomEventProcessingPipelineTest.java#L69](https://github.com/flowable/flowable-engine/blob/master/modules/flowable-event-registry/src/test/java/org/flowable/eventregistry/test/CustomEventProcessingPipelineTest.java#L69)

In the future, we want to improve the support there to do this without code changes.

---

<div class="post-metadata">

**Author:** ![akakunin](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/akakunin/32/1302_2.png) [@akakunin](https://forum.flowable.org/u/akakunin)\
**Post date:** [October 28, 2020, 9:49pm UTC](https://forum.flowable.org/t/more-complex-event-registry-payload-description/6872/5 "2020-10-28T21:49:44Z")

</div>

Hi Joram! Thank you very much for advice! I will try to implement with using these custom components.

---

<div class="post-metadata">

**Author:** ![iadded](https://avatars.discourse-cdn.com/v4/letter/i/9dc877/32.png) [@iadded](https://forum.flowable.org/u/iadded)\
**Post date:** [October 29, 2020, 7:40am UTC](https://forum.flowable.org/t/more-complex-event-registry-payload-description/6872/6 "2020-10-29T07:40:08Z")

</div>

Thanks Joram for this answer  
I just upgraded to version 6.6.0 - and i see there is a new json data type supported for variables.  
I was able to extract the parts of my complex payload as separate json variables - but now i’m trying to figure out how i can use them (for example - how can i use such a variable in an expression in a gateway).  
Are there any examples for this use i can look at as reference ?

Thanks a lot for all the support in this forum  
Inbal

---

<div class="post-metadata">

**Author:** ![akakunin](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/akakunin/32/1302_2.png) [@akakunin](https://forum.flowable.org/u/akakunin)\
**Post date:** [November 6, 2020, 11:11am UTC](https://forum.flowable.org/t/more-complex-event-registry-payload-description/6872/7 "2020-11-06T11:11:22Z")

</div>

Hi Inbal!  
I was not able to find information about json variables. Can you share sample of “payload” in event definition to accept complex json data?

---

<div class="post-metadata">

**Author:** ![akakunin](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/akakunin/32/1302_2.png) [@akakunin](https://forum.flowable.org/u/akakunin)\
**Post date:** [November 6, 2020, 12:12pm UTC](https://forum.flowable.org/t/more-complex-event-registry-payload-description/6872/8 "2020-11-06T12:12:28Z")

</div>

OK, actually I found how to map json in event registration (just to use json variable type). Everything is ok - JSON value passed from Kafka to Flowable Process.  
Now same question as Inbal asked - how can I operate with this variable in task form (for example)? Any samples?

---

<div class="post-metadata">

**Author:** ![iadded](https://avatars.discourse-cdn.com/v4/letter/i/9dc877/32.png) [@iadded](https://forum.flowable.org/u/iadded)\
**Post date:** [November 7, 2020, 5:02pm UTC](https://forum.flowable.org/t/more-complex-event-registry-payload-description/6872/9 "2020-11-07T17:02:17Z")

</div>

Hi

I managed to work with those json variables.  
In the event definition - i set the variable with type = json.  
Then in my flow built using Modeler - i could not set the variable as json - so i ended up saving the xml of the flow and editing it to define the variable as json as well.  
And now i could use it easily.  
e.g. my incoming json was  
{“eventKey”:“newImportFileEvt”, “file”:{“key”:“abcd”, “type”:“csv”}}  
So my variable called “file” with type = json holds {“key”:“abcd”, “type”:“csv”} and i managed to use this in expressions like file.key & file.type

Hope i’m doing it the right way … works for me  
Inbal

---

<div class="post-metadata">

**Author:** ![akakunin](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/akakunin/32/1302_2.png) [@akakunin](https://forum.flowable.org/u/akakunin)\
**Post date:** [November 8, 2020, 10:36am UTC](https://forum.flowable.org/t/more-complex-event-registry-payload-description/6872/10 "2020-11-08T10:36:48Z")

</div>

Hi Inbal!  
Can you share part of process definition?  
My problem: I defined variable in eventRegistry definition (payload part) as json.  
In Process Definition I also defined it as JSON  
`<flowable:eventOutParameter xmlns:flowable="http://flowable.org/bpmn" source="event" sourceType="json" target="event"></flowable:eventOutParameter>`

Then I’ve added Script Task with simple script:

> ```
> org.slf4j.LoggerFactory.getLogger("theScriptTask").info("event Value: {}", event);
> org.slf4j.LoggerFactory.getLogger("theScriptTask").info("event type: {}", typeof event);
> 
> ```

I can see value of my variable and type object:

> 2020-11-08 13:16:44.596 INFO 8244 — [task-1] theScriptTask : event Value: {“from”:“F”,“to”:“D”,“amount”:570.0,“ALERT\_REASON”:“Transaction to high”}  
> 2020-11-08 13:16:44.601 INFO 8244 — [task-1] theScriptTask : event type: object

Everything is OK so far. BUT:

- I cannot access any attributes - event.from, event.to returns undefined
- If I’m trying to call (in ScriptTask) Object.keys(event) I’ve received exception “event is not Object”

So, still question how to access attributes of specific json variable, received from event. ANy advice will be really helpful!

---

<div class="post-metadata">

**Author:** ![akakunin](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/akakunin/32/1302_2.png) [@akakunin](https://forum.flowable.org/u/akakunin)\
**Post date:** [November 8, 2020, 10:46am UTC](https://forum.flowable.org/t/more-complex-event-registry-payload-description/6872/11 "2020-11-08T10:46:01Z")

</div>

OK, partially answered to my question.  
Varialbe with type “json” passed into ScriptTask not as JavaScript Object, but as " \* com.fasterxml.jackson.databind.node.ObjectNode" object.  
So,

> event.get(“ALERT\_REASON”)

getting me required variable.

---

<div class="post-metadata">

**Author:** ![iadded](https://avatars.discourse-cdn.com/v4/letter/i/9dc877/32.png) [@iadded](https://forum.flowable.org/u/iadded)\
**Post date:** [November 8, 2020, 12:08pm UTC](https://forum.flowable.org/t/more-complex-event-registry-payload-description/6872/12 "2020-11-08T12:08:17Z")

</div>

This is how i defined my variable from the event

\<flowable:eventOutParameter source=“file” sourceType=“json” target=“file” targetType=“json”\>\</flowable:eventOutParameter\>

And this is how i used it for generating the payload for the next event

\<flowable:eventInParameter sourceExpression="${file.key}" target=“fileKey” targetType=“string”\>\</flowable:eventInParameter\>

Hope this helps
