public SubscriptionInfo Unsubscribe(Topic topic, Subscriber subscriber)
        {
            topic.Requires("topic").IsNotNull();
            subscriber.Requires("subscriber").IsNotNull();

            if (isDisposed)
            {
                throw new ObjectDisposedException(MethodBase.GetCurrentMethod()?.DeclaringType?.Name,
                    "instance has been disposed");
            }

            var key = GetKey(topic, subscriber);
            SubscriptionInfo subscriptionInfo;
            if (subscriptions.TryRemove(key, out subscriptionInfo))
            {
                subscriptionInfo.CancelToken.Cancel();
                if (!subscriber.LongLived || resourceCounter.Decrement(subscriptionInfo.Subscriber.Name) == 0)
                {
                    amazonSnsFacade.UnsubscribeQueueFromTopic(subscriptionInfo.SubscriptionArn);
                }
                subscriptionInfo.CancelToken = null;
                subscriptionInfo.SubscriptionArn = null;
            }
            return subscriptionInfo;
        }
        public void Publish(Topic topic, string subject, string message)
        {
            topic.Requires().IsNotNull();
            subject.Requires().IsNotNullOrWhiteSpace();
            message.Requires().IsNotNullOrWhiteSpace();

            amazonSnsFacade.PublishMessageToTopic(topic.TopicArn, subject, message);
        }
        public bool IsSubscribed(Topic topic, Subscriber subscriber)
        {
            topic.Requires("topic").IsNotNull();
            subscriber.Requires("subscriber").IsNotNull();

            if (isDisposed)
            {
                throw new ObjectDisposedException(MethodBase.GetCurrentMethod()?.DeclaringType?.Name,
                    "instance has been disposed");
            }

            var key = GetKey(topic, subscriber);
            return subscriptions.ContainsKey(key);
        }
        public SubscriptionInfo Subscribe(Topic topic, Subscriber subscriber, Action<Message> messageHandler)
        {
            topic.Requires("topic").IsNotNull();
            subscriber.Requires("subscriber").IsNotNull();
            messageHandler.Requires("messageHandler").IsNotNull();

            if (isDisposed)
            {
                throw new ObjectDisposedException(MethodBase.GetCurrentMethod()?.DeclaringType?.Name,
                    "instance has been disposed");
            }

            var key = GetKey(topic, subscriber);
            return subscriptions.AddOrUpdate(key, k => AddSubscription(topic, subscriber, messageHandler),
                (x, s) => UpdateSubscription(s, messageHandler));
        }
        public void Publish(Topic topic, string subject, string message)
        {
            topic.Requires("topic").IsNotNull();
            subject.Requires("subject").IsNotNullOrWhiteSpace();
            message.Requires("message").IsNotNullOrWhiteSpace();

            if (isDisposed)
            {
                throw new ObjectDisposedException(MethodBase.GetCurrentMethod()?.DeclaringType?.Name,
                    "instance has been disposed");
            }

            amazonSnsFacade.PublishMessageToTopic(topic.TopicArn, subject, message);
        }