rabbitmq what is difference between SubscribeAsync and PublishAsync in C# - c#

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

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

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

Sending and receiving information with Kafka

Is it possible to use kafka like api?
It means to send a message and wait to receive the answer.
I have just started programming with Kafka and I have a question about sending messages and receiving processing results.
Producers send events, and you can wait for an acknowledgement from the broker server, yes.
No, you cannot await receiving the consumer in the same action, because that is a separate Kafka function, and consumers poll from topics, rather than listen to the client-local producer events.

Retrieve only messages that publisher send after subscriber connected(masstransit)

I have created an application that works using MassTransit and Azure Service Bus as transport. Publish, send, retrieve events and commands - this is all works good. But now I want to create subscriber that will retrieve messages that publisher send after subscriber connected. How to do that? I do not want to get all messages that was sended by publisher before connection.
What you are asking for is not possible.
By definition, a publisher only sends to subscribers. If a subscriber is not connected at the time an event is published, that subscriber would not receive it. Only the subscribers that are connected at the time the event is published receive the event.
In the future, MassTransit will add support for Kafka and Event Hub, which will support what you want, but the semantics for those transports are quite different.

SignalR Replaces Message Queue

Does SignalR replaces MSMQ or IMB MQ or Tibco message queues.
I have gone through SignalR.StockTicker
If we extend the functionality to read Stock tickers from multiple data sources and display to UI, will lit replaces usage of Message Queue
SignalR is designed for real-time messaging using several protocols (WebSockets, Long Polling, Server Sent Events, or Forever Frame). On the other hand, Service Bus type protocols (Such as MSMQ, RabbitMQ, Azure Service Bus) are designed for decoupled communication. The use cases can overlap, but in general, if you're looking for real-time updates (chat, tickers, notifications of a user status change) then SignalR is a good solution. One key difference is that MSMQ and the like do not require that the recipients, or subscribers, be online at the time the message is sent, whereas a SignalR client must be listening or it will miss the notification.
HTH

WCF's publisher subscriber pattern

I have been using WCF for a fair bit now, and I have come across several articles on MSDN regarding WCF's publisher subscriber model.
One of the requirements in a project I'm about to embark on requires me to have one server send out messages to multiple servers, thus, I have a few queries regarding the publisher/subscriber model
My primary concern with the this is:
What happens if 2 out of 5 of my subscribers are disconnected, due to say, PC rebooting. Do I have to manually handle the publisher re-sending the messages to the 2 subscribers when they reconnect back?
I need each message sent out by the publisher to positively reach all the other subscribers, if they are offline, the publisher has to be responsible to re-send the messages when the subscribers are back online. Because there can be a lot of messages being sent by the publisher, does that mean I will need some sort of queuing mechanism to store all the messages that are supposed to be sent to the offline subscribers, and re-send them when they are back online?
Is using WCF's publisher/subscriber mode fitting in my scenario? Are there any models out there that supports disconnected subscribers, automatically resending when the subscriber is back online, or do I have to custom code every single aspect to handle this?
You can try MSMQ, WCF supports it. The publisher will send the messages to 5 queues; each consumer will read its queue.

How to implement single publisher and multiple subscribers asynchronous message system in C# using WCF and MSMQ?

I have searched a lot, but still I had few doubts about MSMQ implementation of WCF service.
Hence I have put this quetion.
I want to implement single publisher and multiple subscribers asynchronous message system.
I have decided to use WCF service as the publisher.
I have multiple instances of the window service on different machines as the multiple subscribers.
Q. I want to know that, how this model can be implemented as the old MSMQ approach?
The object of following type would be used in the message
[Serializable]
public class Message
{
public string Signal{get;set;}
public Guid Identifier{get;set;}
}
In the above class, Identifier would be used by the windows service to decide whether the message was published for that service or not.
Q. How the different window services will read the same queue?
Q. Where the queue should be hosted?
Q. Is it possible to send the acknowledgement from Window service(subscriber) to WCF service(publisher)?
Any help would be appreciated.
In answer to your questions:
I want to know that, how this model can be implemented as the old
MSMQ approach?
First off, MSMQ does not support publish subscribe out of the box.
How the different window services will read the same queue?
So in publish subscribe, there in no ONE queue. Instead there are multiple queues, in fact one per participant in the pub sub scenario. So each publisher has a queue and each subscriber has a queue.
This configuration enables subscribers to send subscribe/unsubscribe messages to the publisher, and allows the publisher to send messages to the subscribers as necessary after evaluating the subscriptions.
Where the queue should be hosted?
These queues can be hosted locally to each participant, or can be hosted together in some clustered location.
Is it possible to send the acknowledgement from Window
service(subscriber) to WCF service(publisher)?
MSMQ does provide basic support for request/response messaging via response-queue and correlation-id message header fields, though this is not truly out of the box (as you are required to consume and program against these values)
If you are not required to use WCF there is a fairly mature platform called nservicebus which sits on top of MSMQ and does provide support for all the messaging patterns you need.

Categories