Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I am new to .NET/C# and I am wondering how oyu could achieve the following scenario:
I need a REST Api with has one endpoint, which accepts a message(string).
That message should be stored in a Queue and then there should be one or multiple Threads that consume and process this Queue.
I do not want to use Hangfire, RabbitMq etc. The only thing that I have seen is to use NancyFx to create the Rest API in a Console application and from there I can achieve the described scenario, but is it possible in .NET Core WebApi, because you cannot create Threads there ?
You can use Asp.Net Core Webapi and use Task Instead of Thread. If you don't use any other third parties such as RabbitMq, Redis, or other message queue, you have to create a shared variable such as a Dictionary or a List and implement synchronization mechanism (such as using Lock) by yourself to avoid any problem caused by concurrency.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I display some of the data i.e. Sum, Average and Total on a page and want to update them after the data changed using SignalR. Most of the examples uses the following approach that broadcast all of the clients after create / update / delete methods (that change data) are executed:
private void BroadcastDataChange(Data data)
{
Clients.All.dataChanged();
}
However, I am wondering if there is a smarter approach that let me update the data i.e. periodically refreshing without broadcast in each of the create-update-delete methods (I do not use SqlDependency, etc, juts using SignalR). On the other hand, I am not sure this kind of approach is contradictory to the SignalR logic. This is the first time I use SÄ°gnalR and I am too confused :( Any help would be appreciated.
You can use polling with SignalR. It's just an inefficient way of doing things though, because: (1) there would be a delay between when changes happen and when they are broadcast to clients. (2) broadcasts would happen even if data didn't change, which is a waste of resources.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I would like to build a c# spa application using angular with real-time messaging signal-r. The signal-r should read the data continuously from a data source and publish the updated data to the user and store the data in a database as well. It should also enable the chatting of the users.The expected number of users is around a hundred.
For such application what should be the best architectural structure of the solution? Should I implement two (three?) projects, e.g. one for the web app and the other for the signal-r, running as two applications? Then, in this case, how can I do the messaging between the applications? Or should I implement a single project for all of these? It would be best if you can provide the pros and cons of these alternatives or provide any other option.
Start with one project.
For 100 simultaneous users, you aren't even close to worried about load. Any simple hosting plan would take care of it easily. If you get more, ASP.NET and SignalR work just fine behind a load balancer (though certain operations can get more complicated).
A properly architected application won't be difficult to split into multiple processes in the future if it ever came to that, and doing so now is just adding mounds of complexity for no appreciable benefit. This goes double since it sounds like you are just starting out.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I've got some work to do for school around Microservices.
I've got the architectural concept, but need an implementation to show off. I'll be using angular2 as a client, would like to use a .NET core API gateway to dispatch my requests to different services.
What's the best approach for this? I red something about using Rx.Net, but no definitive example or implementation that I can follow.
So what should I do to implement an API gateway in .NET Core?
This may or may not help but I am currently building an API gateway in .NET core.
You can find it at https://github.com/TomPallister/Ocelot.
The code is a little ropey but a few people are working on it now so hopefully we can improve it over time.
You want to have a server that listens to the incoming API calls, e.g. a HttpListener.
Inside the handler of incoming requests, you peek into the request and decide where the API call needs to be relayed.
Then you use something like a HttpClient to make another request to the actual API endpoint (mimicking the original request as closely as possible) and you relay its response back to the user.
It should all be in the listener's request handler, and the response to the original request is the response from the real API.
See MSDN docs on HttpListener.
Also a good read: Handling multiple requests with C# HttpListener
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have a question regarding a Windows C# services.
Is it possible for the window service to run in background and send/Receive its data to a C# standalone application with opened by a user. if so how is it that it can be done?
Is there any other better ways for building a window service
Yes this can be done, and there are several options. For inter-process communication - which is basically what you are asking for - you could consider WCF with NamedPipes or TCP, or a message queue (MSMQ, RabbitMQ etc).
Typically with a message queue the messages will queue if the service or client is not there, or with named pipes or TCP a current connection must be available.
WCF named pipe minimal example
Yes, it's possible. You can run a service like windows service, expose methods, and one or more client can use it.
One example is this.
Bye bye.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I am trying to incorporate RabbitMQ based pub sub for a specific programming scenario,
I have a Web API endpoint. When I get a 201 response from this service I want to send out emails.
I already have another API endpoint which I can call to send out email.
Where do I setup the mailer?
And how do I setup RabbitMQ to handle this scenario?
To clarify further, should this be a fanout exchange setup or not? And how are mails usually handled transient or persistent queues?
Sounds like a typical worker scenario where one side will queue up jobs/messages into a message queue (producer) and the other side will get the messages and process them (consumer/worker). In your case, the workers will get messages and send out an email (or hit your api endpoint that sends out emails). The workers typically run on separate machines so they can do work without affecting your application or api.
If you're using RabbitMQ, you should read the "Work Queues" tutorial to see how to set it up for your scenario: http://www.rabbitmq.com/tutorials/tutorial-two-python.html
There are some hosted solutions specifically for this too that don't require any setup like IronMQ for a message queue. Or even a step further if you don't want to deal with worker servers, you can use IronWorker.