v3.12.0
- Support custom startup subscriptions on message handlers
SubscriptionModeAttribute
can now be configured with the type of a custom IStartupSubscriber
. The startup subscriber will be used to create the startup subscriptions for the target message handler.
Complete example:
[SubscriptionMode(typeof(StartupSubscriber))]
public class CustomSubscriptionHandler : IMessageHandler<RoutableEvent>
{
public void Handle(RoutableEvent message)
{
}
public class StartupSubscriber : IStartupSubscriber
{
private readonly IBus _bus;
public StartupSubscriber(IBus bus)
{
_bus = bus;
}
public IEnumerable<BindingKey> GetStartupSubscriptionBindingKeys(Type messageType)
{
if (messageType != typeof(RoutableEvent))
throw new NotSupportedException();
yield return new BindingKey(_bus.PeerId.ToString());
}
}
}