开发者

JMS Queues that require a selector

开发者 https://www.devze.com 2023-04-05 21:33 出处:网络
I want to implement a JMS Queue to ensure that each message is only delivered to one consumer. There will be many different types of consumers on li开发者_高级运维stening to the queue. Messages should

I want to implement a JMS Queue to ensure that each message is only delivered to one consumer. There will be many different types of consumers on li开发者_高级运维stening to the queue. Messages should have properties set which identify the type of work required and these are used by the consumers selector to ensure that they only get sent work which they can handle.

My question is how can I make sure that when a consumer registers with the Queue as a consumer that they implement a selector to avoid the following scenario.

If I have 3 message types (A, B and C) and 3 consumers (a, b and c) which each consume only 1 message type as follows: a->A b->B c->C then all messages of type A will be sent to 1, all messages of type B will be sent to 2 etc.

I want to prevent someone registering a new consumer (d) which has no selector because this consumer would mean that messages of type A,B,C would now either go to their intended consumer or possibly consumer d.

Alternatively I would like the queue to give preference to consumers which have a selector that matches over a consumer with no selector.

Ps. The list of possible consumers and message types is dynamic and not in my control which I why I don't have a queue for each message type.


You cannot achieve it on the JMS API implementation level. I think your best bet is to impose security restrictions on the queue in the broker, like a user/password that your application has to supply to read the queue, and that only your application will know. Consult your JMS provider docs how to do it, it is a standard feature for any serious JMS provider.

I have a feeling you don't want it for security reasons, but for stability, your own peace of mind, or "just in case". You'll probably have to convince whoever-administers-the-queues in your company this is justified.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号