Skip to content

Subscription Options ​

The SubscriptionOptions configured as HopperOptions.Subscription represent common options related to subscriptions.

Any implementation of the ISubscriptionService interface should make use of these options to register, or ensure, any subscriptions:

c#
services.AddHopper(options => 
{
    options.Subscription.Mode = SubscriptionMode.Standard; // default
    
    // add subscription to message types directly:
    options.Subscription.MessageTypes.Add(typeof(Event1).FullName);
})
.AddSubscription<Event1>()
.AddSubscription(typeof(Event2));

And the JSON configuration structure:

json
{
  "Shuttle": {
    "Hopper": {
      "Subscription": {
        "Mode": "Standard",
        "CacheTimeout": "00:05:00",
        "MessageTypes": [
          "message-type-a",
          "message-type-b"
        ]
      }
    }
  }
}

Options ​

OptionDefaultDescription
ModeStandardIndicates how subscriptions are dealt with:
- Standard is the default and will subscribe to the given message type(s) if they have not been subscribed to yet.
- FailWhenMissing will check to see that the subscription exists and if not will throw an exception.
- Disabled will simply ignore the subscription request.
CacheTimeoutnullHow long event subscribers should be cached for before refreshing the list.

When moving to a non-development environment it is recommended that you make use of the FailWhenMissing option for the Mode.