Exemple #1
0
        internal static async Task <ITopic> ForAsync(AzureServiceBusConfiguration configuration, MessageSerializer messageSerializer, Type eventType)
        {
            var topicPath = Conventions.TopicPath(eventType);

            var namespaceManager = NamespaceManager.CreateFromConnectionString(configuration.ConnectionString);

            if (!namespaceManager.TopicExists(topicPath))
            {
                await namespaceManager.CreateTopicAsync(topicPath);
            }

            var messagingFactory = MessagingFactory.CreateFromConnectionString(configuration.ConnectionString);

            var sender = await messagingFactory.CreateMessageSenderAsync(topicPath);

            return(new Topic(messageSerializer, sender, eventType));
        }
        public static async Task <IQueue> ForAsync(AzureServiceBusConfiguration configuration, MessageSerializer messageSerializer, IQueueInstance queue)
        {
            var queueName = Conventions.QueuePath(queue.Name);

            var namespaceManager = NamespaceManager.CreateFromConnectionString(configuration.ConnectionString);

            if (!namespaceManager.QueueExists(queueName))
            {
                await namespaceManager.CreateQueueAsync(queueName);
            }

            var messagingFactory = MessagingFactory.CreateFromConnectionString(configuration.ConnectionString);

            var sender = await messagingFactory.CreateMessageSenderAsync(queueName);

            var receiver = await messagingFactory.CreateMessageReceiverAsync(queueName, ReceiveMode.PeekLock);

            return(new Queue(sender, receiver, messageSerializer, queueName, queue));
        }
Exemple #3
0
        internal static async Task <ISubscription> ForAsync(AzureServiceBusConfiguration configuration, Type eventType, string subscriptionName)
        {
            var topicPath = Conventions.TopicPath(eventType);

            var namespaceManager   = NamespaceManager.CreateFromConnectionString(configuration.ConnectionString);
            var subscriptionExists = await namespaceManager.SubscriptionExistsAsync(topicPath, subscriptionName);

            if (!subscriptionExists)
            {
                await namespaceManager.CreateSubscriptionAsync(topicPath, subscriptionName);
            }

            var messagingFactory = MessagingFactory.CreateFromConnectionString(configuration.ConnectionString);

            var subscriptionPath = SubscriptionClient.FormatSubscriptionPath(topicPath, subscriptionName);

            var receiver = await messagingFactory.CreateMessageReceiverAsync(subscriptionPath, ReceiveMode.PeekLock);

            return(new Subscription(receiver, eventType));
        }
Exemple #4
0
 public SubscriptionFactory(AzureServiceBusConfiguration configuration)
 {
     _configuration = configuration;
 }
Exemple #5
0
 public QueueFactory(AzureServiceBusConfiguration configuration, MessageSerializer messageSerializer)
 {
     _configuration     = configuration;
     _messageSerializer = messageSerializer;
 }
Exemple #6
0
 public static IConfigureDependencies AddAzureServiceBusTransportProvider(this IConfigureDependencies configuration, AzureServiceBusConfiguration azureServiceBusConfiguration)
 {
     configuration.Add(azureServiceBusConfiguration);
     configuration.Add <IQueueFactory, QueueFactory>();
     configuration.Add <ITopicFactory, TopicFactory>();
     configuration.Add <ISubscriptionFactory, SubscriptionFactory>();
     configuration.Add <IConsumerFactory, ConsumerFactory>();
     configuration.Add <MessageSerializer>();
     configuration.Add <BrokeredMessageFactory>();
     return(configuration);
 }