Control consumption of multiple JMS queues

2020-04-20 21:22发布

I can't find this information anywhere. I have two queues, @JmsListener(destination = "p1"), @JmsListener(destination = "p2"). How can I make sure I only process 1 message at a time, even though I am listening to 2 queues, and also how do I configure the polling of what queue I get messages from first, that is after processing a message I want to poll p1 first. Or do weighted polling: p1:90%, p2:10%. Etc.

Basically I am asking how to implement priority processing of messages for Spring. I'm using SQS which doesn't support priorities.

1条回答
一纸荒年 Trace。
2楼-- · 2020-04-20 21:47

Use one of the JmsTemplate receive() or receiveAndConvert() methods instead of the message-driven model.

Use transactions if you want to ensure no message loss.

查看更多
登录 后发表回答