我正在使用 Spring Batch Integration,因为在调用批处理之前我必须执行某些工作.
I am using Spring Batch Integration as I have to perform certain works before invoking the batch.
我已经使用 Spring Integration 完成了这项工作,并使用 job-launching-gateway 调用了批处理,它的工作原理非常棒.现在的问题是如何将数据从 Spring Integration 传递到 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?
请提出建议.
推荐答案发送到 JobLaunchingGateway 的消息有一个 JobLaunchRequest 负载.
The message sent to the JobLaunchingGateway has a JobLaunchRequest payload.
在 Spring Integration 流程中构建请求时,您可以添加 JobParameters,然后在批处理作业中使用.
When you build the request in your Spring Integration flow, you can add JobParameters which are then used within the batch job.
编辑
对于自定义对象,您必须间接进行.例如通过 Map.
For custom objects you would have to do it indirectly. For example via a Map.
如果您使用的是 XML 配置,则可以使用:
If you are using XML configuration, you can use a:
... </...>
将您的对象填充到某个键下的映射中,将键作为 JobParameter、@Autowire 传递到您的批处理作业中,然后使用键.
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.
更多推荐
Spring Batch Integration
发布评论