Home > Back-end >  rabbitmq what is difference between SubscribeAsync and PublishAsync in C#
rabbitmq what is difference between SubscribeAsync and PublishAsync in C#

Time:11-28

I'm using rabbitmq in my microservices project and I saw these two methods what are these and when do we use each

enter image description here

enter image description here

CodePudding user response:

I suspect you're using something on top of RMQ, like EasyNetQ, because these aren't rabbit terms specifically, but in essence:

Publish publishes messages to a queue

Subscribe subscribes to a queue and defines the code that will act on the received message

CodePudding user response:

A producer is a user application that sends messages while a consumer is a user application that receives messages.A queue is a buffer that stores those messages. https://dev.to/mashaa/introduction-to-rabbitmq-49n8

In many pub/sub systems, publishers post messages to an intermediary message broker or event bus, and subscribers register subscriptions with that broker, letting the broker perform the filtering. The broker normally performs a store and forward function to route messages from publishers to subscribers. In addition, the broker may prioritize messages in a queue before routing. https://en.m.wikipedia.org/wiki/Publish–subscribe_pattern

The core idea in the messaging model in RabbitMQ is that the producer never sends any messages directly to a queue. Actually, quite often the producer doesn’t even know if a message will be delivered to any queue at all. https://www.rabbitmq.com/tutorials/tutorial-three-python.html

  • Related