Publish/Subscribe vs Producer/Consumer?

后端 未结 3 1359
生来不讨喜
生来不讨喜 2021-01-01 16:08

From messaging point of view with systems like kafka, rabbit, hornet mq, activemq etc... Is there a difference between pub/sub and prod/con or are they used interchangeably?

3条回答
  •  独厮守ぢ
    2021-01-01 16:34

    There is a difference between the publish/subscribe and producer/consumer models.

    Publish/Subscribe : Subscribers subscribe to the publisher. Each message the Publisher publishes is sent to all the subscribers. That is, all subscribers receive the same message. (Think of a newspaper or magazine subscription. All subscribers receive the same magazine or newspaper)

    Producer/Consumer : Each message the producer produces will be consumed by a single consumer. This is a mechanism to distribute the work load to multiple consumers. (Think of the several cash registers at the supermarket. Each customer goes to a single cash register. The customers are like the messages that are produced and the cash registers are the consumers)

提交回复
热议问题