SignalR Replaces Message Queue - c#

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

Related

rabbitmq what is difference between SubscribeAsync and PublishAsync in 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

Does MassTransit support MSMQ over HTTP transport?

HTTP transfer has been available since MSMQ 3.0, however I'm afraid MassTransit doesn't offer the feature to use HTTP protocol as transport protocol between queues.
There's a very similar question about this here, which has not been completely answered.
Does anyone know if it's possible for a client to subscribe to a bus and send/receive messages through HTTP? Here's the architecture I'm willing to implement:
I'll have 2 computers in the local network
Computer A runs a server application and MassTransit.RuntimeServices
Computer B runs a client application which sends messages to A
I want the communication between them to be done via http.
I tried to change the address in UseSubscriptionService to http instead of msmq, but it doesn't work. If I set computer's A MSMQ service to Hardened Mode, the client application running on computer B get's a timeout while trying to subscribe to mt_subscriptions.
Bus.Initialize(sbc =>
{
sbc.UseMsmq();
sbc.VerifyMsmqConfiguration();
sbc.UseMulticastSubscriptionClient();
sbc.ReceiveFrom("msmq://localhost/test_queue_client");
sbc.UseSubscriptionService("msmq://m3-dev1/mt_subscriptions"); // maybe I could use http instead of msmq, but it doesn't work
});
Any clues on that??
No, MassTransit does not support HTTP for MSMQ. You could, in theory, add your own transport that supports that. RabbitMQ is a way better transport than MSMQ in every way except if you need to enroll in distributed transactions. And RabbitMQ only requires a single port open between the boxes.
Our approach for distributed integration is to have a custom web service contract with proper security. This defines an input port. The input port actually publishes messages to mass transit buses.
On the other side, the same contract is used to deliver messages to subscribers.
By having a custom contract and http/https transport we are independent on actual message bus in the middle. And this pays of, we were using another bus for like 2 years and 2 years ago we migrated to mass transit based bus without ANY changes to clients (publishers/subscribers).

WCF - NetMsmqBinding vs NetTcpBinding

I was going through this article http://weblogs.asp.net/spano/archive/2007/10/02/choosing-the-right-wcf-binding.aspx to choose Binding options.
where i got an unusual doubt of what is mean by
offline or disconnected interaction, choose the NetMsmqBinding
Does that mean the even if service is not running still client using the service ?
Can you share some real time example ?
The 2 bindings are radically different.
NetTcpBinding can be thought of as an MS proprietary format (usually binary) similar in concept to RPC (e.g. can be used to replace .NET Remoting). It is synchronous, i.e. both client and server must be online at the same time, and the client receives a response (almost) immediately.
MSMQ is a Message Oriented Middleware solution by Microsoft, which revolves around asynchronous queues - e.g. if the destination server is offline when the client sends a message, the message will be queued on the client until the server comes back online. Each queue is one way only, although bidirectional communication can be achieved via a second queue back from server to client. Sending WCF MSMQ messages requires that the MSMQ Service be installed on the client. Messages on the queue can have a delivery 'timeout' else will be placed on an applicable dead letter queue.
Real world examples:
I would use NetTcpBinding with binary serialization for high performance, synchronous communication needs between a Microsoft WCF client and server, e.g. uploading files, media etc where Xml would not be useful (otherwise, I would use wsHttpBinding for synchronous Xml / SOAP messaging)
I would use MSMQBinding with DTC enabled to ensure reliable messaging between 2 or more systems (e.g. financial), with at least one of the endpoints being in .Net, and a 'compatable' server (not necessarily WCF, e.g. BizTalk, or other EAI hubs or ESB buses which have adapters for MSMQ, e.g. Bridges exist between MSMQ and MQSeries). Messages would typically be in an Xml format.
TL;DR
Does that mean the even if service is not running still client using the service
Yes. If MSMQ is running locally, the client will get an immediate return successful response (indicating that the message has been queued). This does not however mean that the message has been successfully received by the server.

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