JMS Topic vs Queues

前端 未结 9 2092
广开言路
广开言路 2020-12-04 04:48

I was wondering what is the difference between a JMS Queue and JMS Topic.

ActiveMQ page says

Topics

In JMS a Topic implements <

相关标签:
9条回答
  • 2020-12-04 05:09

    If you have N consumers then:

    JMS Topics deliver messages to N of N JMS Queues deliver messages to 1 of N

    You said you are "looking to have a 'thing' that will send a copy of the message to each subscriber in the same sequence as that in which the message was received by the ActiveMQ broker."

    So you want to use a Topic in order that all N subscribers get a copy of the message.

    0 讨论(0)
  • 2020-12-04 05:09

    TOPIC:: topic is one to many communication... (multipoint or publish/subscribe) EX:-imagine a publisher publishes the movie in the youtub then all its subscribers will gets notification.... QUEVE::queve is one-to-one communication ... Ex:-When publish a request for recharge it will go to only one qreciever ... always remember if request goto all qreceivers then multiple recharge happened so while developing analyze which is fit for a application

    0 讨论(0)
  • 2020-12-04 05:12

    That means a topic is appropriate. A queue means a message goes to one and only one possible subscriber. A topic goes to each and every subscriber.

    0 讨论(0)
  • 2020-12-04 05:12

    Queues

    Pros

    • Simple messaging pattern with a transparent communication flow
    • Messages can be recovered by putting them back on the queue

    Cons

    • Only one consumer can get the message
    • Implies a coupling between producer and consumer as it’s an one-to-one relation

    Topics

    Pros

    • Multiple consumers can get a message
    • Decoupling between producer and consumers (publish-and-subscribe pattern)

    Cons

    • More complicated communication flow
    • A message cannot be recovered for a single listener
    0 讨论(0)
  • 2020-12-04 05:15

    As for the order preservation, see this ActiveMQ page. In short: order is preserved for single consumers, but with multiple consumers order of delivery is not guaranteed.

    0 讨论(0)
  • 2020-12-04 05:16

    Topics are for the publisher-subscriber model, while queues are for point-to-point.

    0 讨论(0)
提交回复
热议问题