Clients use iOS app + RabbitMQ to send messages on the server.
Sellers use ASP.NET MVC web site.
How can I use RabbitMQ for ASP.NET MVC to get messages from server?
If I subscribe to RabbitMQ channel as consumer inside controller, this doesn't work because controller returns View and EventHanlder doesn't fire.
You can create subscribing and recieving message from rabbitmq in global.asax or startup or program (if this selfhost) or another place which can be initialized on start. ASP.NET mvc in this case doesn't matter.
Related
I'm working with a project built with ASP.NET Core 2.2. The main solution contains multiple projects, which includes API, web and other class libraries.
We've used SignalR to displaying shared messages/notifications between the API project and the web project. For example, adding a new employee record from an API should call SignalR Hub and all the web client should received the notification.
To make it communicate, we have used Radis with SignalR
// SignalR Configuration
services.AddSignalR(option =>
{
option.EnableDetailedErrors = true;
option.KeepAliveInterval = TimeSpan.FromSeconds(3);
}).AddStackExchangeRedis(options =>
{
options.Configuration.ChannelPrefix = "TestChannel";
options.Configuration.EndPoints.Add("127.0.0.1", 6379);
options.Configuration.ClientName = "ClientNameSignalR";
options.Configuration.AllowAdmin = true;
});
When I try to get client list in Radis,
Now, how to sending and receiving messages from web app and API?
The code you share is used to set up a Redis backplane for scaling out your ASP.NET Core SignalR app.
how to sending and receiving messages from web app and API?
To achieve above requirement, you can do:
For your API project and Hub server, you can inject an instance of IHubContext in your API controller, then you can access to an instance of IHubContext in controller action and push message/notification to client(s).
Access a SignalR IHubContext to send notifications to clients from outside a hub
For your web app, you can built and implement SignalR JavaScript client functionality to receive notifications.
SignalR JavaScript client
I have:
ASP.NET MVC site for sellers.
A separate server which uses RabbitMQ to send messages.
How can I get these messages at cshtml page? I can subscribe to RabbitMQ at server side of ASP.NET MVC and use SignalR to send message to client, but it seems ugly.
I am using WebAPI to develop a REST based communication model for my clients.
To intercept the incoming request and log them, I use a class that is derived from MessageHandler and register it in the WebAPIConfig.
Note: I never happened to work with legacy ASP.NET Web applications.
When I attended an interview yesterday, the interviewer asked about HttpHandlers in ASP.NET.
Is the HttpHandler so called MessageHandler in WebAPI or both are different ?
You can say that MesssageHandler is to Web API what HttpModule is to pre-vNext ASP.NET.
An HttpHandler in ASP.NET has a role more similar to an ApiController in Web API request pipeline: it is delegated requests and returns something in response.
Is it possible to use a self hosted signalR server with an MVC(4) application such that it is totally seperate from the signalR server?
I tried Tim and Patrick's beautifully executed SignalR intro tutorial, and was wondering if I could try that? And even if I could, would that offer any performance advantages over an integrated service as is metioned in the tutorial.
It is absolutely possible to self-host a SignalR 2.0 server with OWIN and accessing this server from within any Website (which may be a MVC application). The only thing you need is to enable CORS (app.UseCors(CorsOptions.AllowAll); in your Startup file of the Owin Host) since it's not on the same domain as your Website. Obviously you can't use SignalR within the MVC application itself this way (e.g. to publish messages).
I'm using a self-hosted ASP.NET Web API 2 and SignalR 2 server with OWIN to serve data to clients. You can find an example server using this scenario here. Tho advantage in this approach is to have your views & styles sepparated from your data and business logic. Making everything very easy to cache and scale.
I would like to create a web project using ASP.NET MVC 4 which aims to make use of XMPP for some of its messaging, I have good knowledge of Jabber.net however, what I am a little confused about is the threading model I need to implement to use this type of library with an MVC application.
For example, when a user clicks a button on my page, on the server side, I want to:
connect to the XMPP server
then authenticate
then send an IQ message
then receive a response back
After all this is done, I then want to send the HTTP response message back to the client.
All of this is done using standard event handlers within Jabber.net but this model doesn't traditionally fit with web based threading, unless I am just tired and missing something...
Should I use a WaitHandle to stop the controller thread until the other threads are done with the Jabber.net code, then respond?
Do the async controllers fit here?