Search code examples
c#asp.net-coresignalrpublish-subscribestackexchange.redis

Where to subscribe to Redis event in ASP NET if I want to use DI to react to published event


I use SignalR backplane with Redis. Its my first microservice.

The second microservice must subscribe to channel used to publish SignalR messages. But the problem is about where should I subscribe (in ASP NET app) to this event, if I want to use Dependency Injection (because I want to save published messages to database)?


Solution

  • IHostedService is the way to go - you can inject, what you wants here and set IHostedService for infinite run.