问题
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