0

Below is a simplified flow of the http request pipeline for asp.net-core:

enter image description here

A request comes into the server, a context gets created for the request, and the authentication middleware is able to authenticate a user and place the object on the HttpContext for use in the business logic.

How can I implement an Amqp Server on dotnetcore that could serve and respond to requests from (for example) a RabbitMq server? Outside of the message protocol, I would like to keep most of the features/middleware available on the http pipeline (such as the authentication middleware).

enter image description here

yenta
  • 1,332
  • 2
  • 11
  • 25
  • I’m not really sure what you want to do but you can write custom middleware that does whatever you want to respond to incoming requests. – poke May 28 '19 at 12:11
  • @poke I would like to serve requests that arrive to my service from RabbitMQ, but I would like them to respect Authorization/Authentication/other piepline features already configured for Http without having to write adapters for all of the middleware. – yenta May 31 '19 at 15:22
  • @poke I updated the question to better show my intent – yenta May 31 '19 at 15:50
  • So basically, you want to accept “HTTP-like” requests that don’t come in as HTTP but as RabbitMQ messages? How do these actually look like and can you properly translate them into HttpRequests? Then you could implement your RabbitMQ base as an additional transport layer for your ASP.NET Core application. Otherwise, a better idea would probably be to abstract your business logic and authentication into a separate layer that makes it callable from both ASP.NET Core and the RabbitMQ entry points. – For routing, I am not sure how HTTP routing would possibly translate to queue messages. – poke Jun 02 '19 at 12:56
  • It has a body and headers, no route or path. In the past we have spoofed that through the message headers. And yes, I would like to implement an additional transport layer - is there an example/documentation you know of that I could base work on? – yenta Jun 05 '19 at 08:14
  • ASP.NET Core transport layer stuff is very low level, so you’re best of looking at the source. [Here’s the socket transport](https://github.com/aspnet/AspNetCore/blob/v2.2.5/src/Servers/Kestrel/Transport.Sockets/src/SocketTransport.cs) and [the libuv transport](https://github.com/aspnet/AspNetCore/blob/v2.2.5/src/Servers/Kestrel/Transport.Libuv/src/Internal/LibuvTransport.cs). Note that with 3.0, there will be some changes with how the transport is layered. – poke Jun 05 '19 at 09:17

0 Answers0