Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="eventType"></param>
        /// <param name="original"></param>
        public void Unsubscribe(Type eventType, Address original)
        {
            var publisherAddress = Address.Parse(AzureServiceBusPublisherAddressConvention.Create(original));
            var subscriptionname = AzureServiceBusSubscriptionNameConvention.Create(eventType);

            if (NamespaceClient.SubscriptionExists(publisherAddress.Queue, subscriptionname))
            {
                NamespaceClient.DeleteSubscription(publisherAddress.Queue, subscriptionname);
            }

            // unhook the listener
        }
        public bool Publish(TransportMessage message, IEnumerable <Type> eventTypes)
        {
            var sender = GetTopicClientForDestination(AzureServiceBusPublisherAddressConvention.Create(Address.Local));

            if (sender == null)
            {
                return(false);
            }

            if (Transaction.Current == null)
            {
                Send(message, sender);
            }
            else
            {
                Transaction.Current.EnlistVolatile(new SendResourceManager(() => Send(message, sender)), EnlistmentOptions.None);
            }

            return(true);
        }