Spring Batch Integration - pass data b/w integration and batch

China☆狼群 提交于 2021-02-08 12:01:23

问题


I am using Spring Batch Integration as I have to perform certain works before invoking the batch.

I have done the work using Spring Integration and invoke the batch using job-launching-gateway and it works like a charm. Now the question is how to pass the data from Spring Integration to Batch?

Suggestions please.


回答1:


The message sent to the JobLaunchingGateway has a JobLaunchRequest payload.

When you build the request in your Spring Integration flow, you can add JobParameters which are then used within the batch job.

EDIT

For custom objects you would have to do it indirectly. For example via a Map.

If you are using XML configuration, you can use a:

<util:map id="jobParams"> ... </...>

Stuff your object into the map under some key, pass the key as a JobParameter, @Autowire the map into your batch job and retrieve/remove the object using the key.



来源:https://stackoverflow.com/questions/36469446/spring-batch-integration-pass-data-b-w-integration-and-batch

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