OrleansContrib / Orleans.Providers.MongoDB

A MongoDb implementation of the Orleans Providers: Membership, Storage and Reminders.
MIT License
100 stars 43 forks source link

Call to RegisterOrUpdateReminder throws exception: "No service for type 'Orleans.Timers.IReminderRegistry' has been registered." #115

Closed htxryan closed 1 year ago

htxryan commented 1 year ago

Hello!

I'm facing an issue when upgrading from 3.x to 7.

Calls to RegisterOrUpdateReminder() from grains that implement IRemindable throw exceptions: "No service for type 'Orleans.Timers.IReminderRegistry' has been registered."

As noted here, a reference to Microsoft.Orleans.Reminders has been added.

NOTE: Changing from the MongoDB provider to the in-memory reminder service DOES make this issue go away. So this might be an issue with this library rather than Orleans itself. If someone reading this believes it is an Orleans issue, let me know. I'm going to open this same issue there just in case (https://github.com/dotnet/orleans/issues/8177).

Stack trace:

System.InvalidOperationException: No service for type 'Orleans.Timers.IReminderRegistry' has been registered.
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
   at Orleans.GrainReminderExtensions.GetReminderRegistry(IGrainContext grainContext) in /_/src/Orleans.Reminders/GrainReminderExtensions.cs:line 125
   at Orleans.GrainReminderExtensions.RegisterOrUpdateReminder(Boolean remindable, IGrainContext grainContext, String reminderName, TimeSpan dueTime, TimeSpan period) in /_/src/Orleans.Reminders/GrainReminderExtensions.cs:line 52
   at Orleans.GrainReminderExtensions.RegisterOrUpdateReminder(Grain grain, String reminderName, TimeSpan dueTime, TimeSpan period) in /_/src/Orleans.Reminders/GrainReminderExtensions.cs:line 29
   at [ grain function]...
wassim-k commented 1 year ago

Have you called AddReminders similar to how it's done in our integration test?

htxryan commented 1 year ago

@wassim-k Bingo, that worked! You rock -- thank you for the quick help. Did I just overlook it, or was this not mentioned in the Orleans upgrade docs? Reminders were working for us in 3.x without this call, so it seems like a 7.x breaking change.

wassim-k commented 1 year ago

Yeh, I haven't seen a reference to it in the docs either. I had do some digging into Orleans code to work it out.

htxryan commented 1 year ago

@wassim-k I created a PR to add this call automatically, so no one else gets hung up on this; https://github.com/OrleansContrib/Orleans.Providers.MongoDB/pull/116