I have a project that retrieves data from several tables in different flows and merge them for the result.
I'm wondering if creating a variable for storing the data from each table is correct, as the payload gets overwritten on each request.
Another doubt is the way that I should store those variables, if I should use Java objects, json, xml, ... as I have an internal call to a web service that returns json.
Thanks in advance.
If you do not want to overwrite you existing payload every time yo make a call to the database, then you can use Message Enricher, which will retrieve your data from database without replacing the current payload
ref :- https://docs.mulesoft.com/mule-user-guide/v/3.6/message-enricher
http://forums.mulesoft.com/questions/1266/use-of-message-enricher-in-mule.html
Regarding storing data in your variable depends on how you are going to use that variable.
For example if the data stored in your variable needs by a message processor in the flow as XML, then you need to store it as XML in the variable.
If you want to store a payload in variable that you can use as request for you internal REST service which accept JSON format, then you need to store it as JSON in the variable.
It all depends on how are you going to use the variable.