简体   繁体   中英

JMS topic receive in a Queue listener

I have a question regarding JMS. I´ve been checking some blogs, where show how a sending topic message can be receive by a queue listener. It is that even possible, as far as I know only a client subscribe to a particular topic can receive a message published.

Regards.

So, given you publish to a topic, you want to consume the messages from a queue. I assume you use ActiveMQ since you added that tag.

The main reason for this setup is to be able to load balance multiple cluster nodes of the consumer. Plain durable subscriptions won't allow that in JMS 1.x. I guess your case is similar.

  • In generic JMS, this is not possible. However, in JMS 2.0 durable subscriptions can be load balanced and hence work a bit like queues. Not all JMS brokers implements JMS 2.0. ActiveMQ does not implement JMS 2.0, but ActiveMQ Artemis do.

  • ActiveMQ allows this by a concept called Virtual Topics. Using Virtual Topics you can give the topic a certain name, say VirtualTopic.MyTopic would forward all published messages to any created queue that matches Consumer.MyConsumer.VirtualTopic.MyTopic.

Example topic name:

  • VirtualTopic.GameScores

Example queue names:

  • Consumer.ScoreBoardService.VirtualTopic.GameScores
  • Consumer.BettingService.VirtualTopic.GameScores

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM