I was wondering if it is possible to make use of my services in my subscription callback. So something like this:
var redis = ConnectionMultiplexer.Connect("redis");
var sub = redis.GetSubscriber();
sub.Subscribe("profile:created").OnMessage(channelMessage => {
var profile = JsonConvert.DeserializeObject<Profile>(channelMessage.Message);
//In some way get the profile service
profileService.InsertProfile(profile)
})
The profile service is added as a scoped service in the startup like following:
services.AddScoped<IProfileService, ProfileService>();