MSMQ Subscription Authorization

Component: MSMQ Transport | Nuget: NServiceBus (Version: 6.x)

Subscription Authorization allows the programmatic control over what subscribers can subscribe of unsubscribe.

Edit
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]
        .ToLowerInvariant();
    // true to allow false to decline
    return true;
});

Samples

  • Publish/Subscribe
    Publish/Subscribe, fault-tolerant messaging, and durable subscriptions.

Last modified