.NET/C# REST Api Messages to Queue

1.2k Views Asked by At

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 ?

1

There are 1 best solutions below

0
Alireza Mahmoudi On

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.