I have a JMS publisher, which I cannot change (external system). This publisher publishes messages into some predefined JMS queue. I would like to design a multi-node subscriber system in which all subscribing nodes will receive a copy of each message (in my design, a subscriber node is able to realize if the message is targeted at this node by checking some property inside the message, so only one subscriber node will eventually process the message, while other subscriber nodes will discard their copies).
Changing the publisher system to use Topics could work flawlessly, but I cannot change the publisher.
Currently, I see two options to solve this:
One option which can probably work is to use QueueBrowser, implement periodic polling which will read all messages and if the message is "mine", remove the message from queue and process. This is a huge overhead for such a simple problem.
Another option is to write a dispatcher which subscribes to the queue and dispatches each message to multiple "internal" subscribers (e.g. as explained here: JMS - Going from one to multiple consumers). But this creates bottleneck in the dispatcher killing the whole scalability idea.
A third option is to have multiple "intermediate" queue subscribers, each subscriber, when it receives a message, re-publishes it to a Topic for which the target subscribers will subscribe. This can work, but it's an extra hop in the flow, so not sure if the benefit (scalability) will be worth the loss (latency and complexity).
I wonder if there are any other ideas on how to solve this.
- Can I have a subscriber listening to all topics ?
- Can I configure JMS (WebLogic in my case) to auto-forward messages from queue to some topic?
- Other options?
Thanks.