MSMQ Subscription Authorization

Component: MSMQ Transport
NuGet Package: NServiceBus.Transport.Msmq (2-pre)
This page targets a pre-release version. Pre-releases are subject to change and samples are not guaranteed to be fully functional.

Subscription authorization allows code-level control over what subscribers can subscribe or unsubscribe to.

var routing = endpointConfiguration.UseTransport(new MsmqTransport());

routing.SubscriptionAuthorizer(context =>
    var headers = context.MessageHeaders;

    var subscriptionMessageType = headers[Headers.SubscriptionMessageType];

    // messageIntent will be either MessageIntent.Unsubscribe or MessageIntent.Subscribe
    var messageIntent = (MessageIntent)Enum.Parse(typeof(MessageIntent), headers[Headers.MessageIntent], true);

    var endpointName = headers[Headers.SubscriberEndpoint].ToLowerInvariant();

    // true to allow, false to disallow
    return true;


Last modified