0

Due to my company's applications architecture, I need to develop a Kestrel based web server. The main feature that this web server must have is that it needs to maintain a requests queue whose response will be sent at some point in the future (when another app notifies that it can be sent).

Considering that HttpContext is reused for each request, I don't think it'll be possible.

Does anyone have any idea on how I can deal with this problem?

Thanks in advance.

Merrin
  • 514
  • 7
  • 20
  • 1
    I think you will run into some issues here. The incoming request has a timeout and if no response has been returned, the connection will be closed by the caller. It sounds more like you need an asynchronous communication flow, could be a message bus, webhooks, etc. If the time you need to queue requests are short, you could queue the request with the use of a semaphore (C# semaphoreslim) and use it to control the flow. – xcskilab Sep 25 '21 at 18:18
  • From your description, I assume you want to schedule a background task, and do something at a specific date and time in the future? If that is the case, you could consider using the hosted service, check the following articles: [Background tasks with hosted services in ASP.NET Core](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/host/hosted-services?view=aspnetcore-5.0&tabs=visual-studio), [Thread 1](https://stackoverflow.com/questions/63795334/) and [Thread 2](https://stackoverflow.com/questions/64005363/). – Zhi Lv Sep 27 '21 at 08:37
  • @ZhiLv That's right. The problem is that "something" in the future is to send the response. Thanks for the links, I'll take a look – Merrin Sep 27 '21 at 10:08

0 Answers0