如何在春季批处理中使用单个作业/JMSwriter在多个队列上发布 [英] How to post on multiple queues using single job/ JMSwriter in spring batch
问题描述
我是Spring Batch的新手,最近开始使用它.
I am a newbie at Spring Batch and have recently started using it.
我有一个要求,我需要使用单个Job在不同队列上发布/写入从每个DB记录读取的消息.因为我必须使用阅读器来读取数据库中的消息,并使用处理器来决定必须在哪个队列上发布它.
I have a requirement where I need to post/write the messages read from each DB record on different queues using single Job. As I have to use reader to read the messages from DB and use processor to decide on which queue I have to post it.
所以我的问题是我可以使用单个JMSwriter将消息发布到不同的队列中,因为我必须使用单个Job和DB Reader.
So my question is Can I use single JMSwriter to post the messages on different queues as I have to use single Job and DB Reader.
预先感谢
推荐答案
据我所知,JMSwriter
不支持它(它写入jmsTemplate
的默认目标位置).
As I know JMSwriter
not supports it (it writes to default destination of jmsTemplate
).
但是您可以只实现自己的ItemWriter
,将所有jmsTemplates
注入其中,并编写自定义决策逻辑以选择适当的目标并写入它.
But you may just implement your own ItemWriter
, inject all jmsTemplates
in it and write custom decistion logic to select appropriate destionation and write to it.
另一种方法-使用 ClassifierCompositeItemWriter ,然后放置一组JmsWriters
,然后根据您的分类器选择一个
Another way - use ClassifierCompositeItemWriter , put a set of JmsWriters
to it and select one by your classifier
这篇关于如何在春季批处理中使用单个作业/JMSwriter在多个队列上发布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!