Maintain Payload State during mule flow execution

谁说我不能喝 提交于 2019-12-25 06:59:32

问题


what is the best way to ensure payload state is maintained during a flow execution. I have a flow that performs multiple database and webservice executions, but everytime i perform a connector execution my payload gets lost. to maintain this. To maintain state, all my connector executions are being performed in a message enricher scope and the responses from these outbound connectors are populated in variables. Even though I feel these are a complete waste of memory.

kindly advise.

regards Santosh


回答1:


What would you be doing with the results of these other db / ws calls if you didnt put them in flowVars? Where would you like to hold them?

You are probably doing the right thing to use MessageEnricher if you dont want to loose the original payload.

If you didnt want to put the results of each enricher in vars, you could add them to the message payload itself. If the payload is an instance of map or a pojo with a setter, you can simply add an enrichers result as in:

 <enricher source="#[message.payload]" target="#[message.payload.enricherResult]" doc:name="Message Enricher">

If you wanted to keep the payload original, you could move it into a map as key "original" or something and then add each enrichers result as a new key.

Either way, the fact that you plan to hold on to each enrichers result probably means the same amount of memory is being used whether you put them in flowVars or stuff them into the payload itself.




回答2:


An alternate and simple approach will be, save the message payload into some variable before a DB call or external service call.
You can later retrieve the value from the variable and set it as payload



来源:https://stackoverflow.com/questions/20568646/maintain-payload-state-during-mule-flow-execution

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!