MSMQ Subscription Authorization

Component: MSMQ Transport
NuGet Package NServiceBus (5.x)

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

class AuthorizeSubscriptions :
    IAuthorizeSubscriptions
{

    public bool AuthorizeSubscribe(string messageType, string clientEndpoint, IDictionary<string, string> headers)
    {
        var lowerEndpointName = clientEndpoint.ToLowerInvariant();
        return lowerEndpointName.StartsWith("samples.pubsub.subscriber1") ||
               lowerEndpointName.StartsWith("samples.pubsub.subscriber2");
    }

    public bool AuthorizeUnsubscribe(string messageType, string clientEndpoint, IDictionary<string, string> headers)
    {
        return true;
    }
}

Samples

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

Last modified