MSMQ Subscription Authorization

Component: MSMQ Transport
Target Version: NServiceBus 7.x

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

var transport = endpointConfiguration.UseTransport<MsmqTransport>();
transport.SubscriptionAuthorizer(context =>
    var headers = context.MessageHeaders;
    var subscriptionMessageType = headers[Headers.SubscriptionMessageType];
    var messageIntent = headers[Headers.MessageIntent];
    var messageIntentEnum = (MessageIntentEnum) Enum.Parse(typeof(MessageIntentEnum), messageIntent, true);
    // messageIntentEnum will be either MessageIntentEnum.Unsubscribe or MessageIntentEnum.Subscribe
    var endpointName = headers[Headers.SubscriberEndpoint]
    // true to allow false to decline
    return true;


Last modified