问题
I am a newbie at Spring Batch and have recently started using it.
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.
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.
Thanks in Advance
回答1:
As I know JMSwriter
not supports it (it writes to default destination of jmsTemplate
).
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.
Another way - use ClassifierCompositeItemWriter , put a set of JmsWriters
to it and select one by your classifier
来源:https://stackoverflow.com/questions/15483197/how-to-post-on-multiple-queues-using-single-job-jmswriter-in-spring-batch