コード例 #1
0
        public AzurePublisher(string serviceBusName, string topicName,
                              string serviceBusTokenKeyName,
                              string serviceBusToken)
        {
            var namespaceManager = AzureFunctions.CreateNamespaceManager(serviceBusName,
                                                                         serviceBusTokenKeyName, serviceBusToken
                                                                         );

            //Create the queue if it does not exist already
            if (!namespaceManager.TopicExists(topicName))
            {
                var topicDescription = new TopicDescription(topicName)
                {
                    MaxSizeInMegabytes      = 5120,
                    EnablePartitioning      = true,
                    EnableBatchedOperations = true
                };
                namespaceManager.CreateTopic(topicDescription);
            }


            var messagingFactorySettings =
                new MessagingFactorySettings
            {
                OperationTimeout = TimeSpan.FromMinutes(60),
                TransportType    = Microsoft.ServiceBus.Messaging.TransportType.Amqp,
                TokenProvider    = namespaceManager.Settings.TokenProvider
            };
            var messagingFactory = MessagingFactory.Create(namespaceManager.Address, messagingFactorySettings);

            _topicClient = messagingFactory.CreateTopicClient(topicName);
        }
コード例 #2
0
        public AzureSubscriber(string serviceBusName, string topicName, string subscriptionName,
                               string serviceBusTokenKeyName,
                               string serviceBusToken,
                               ReceiveMode mode,
                               int?prefetchCount = null)
        {
            var namespaceManager = AzureFunctions.CreateNamespaceManager(serviceBusName,
                                                                         serviceBusTokenKeyName, serviceBusToken
                                                                         );

            MessagingFactorySettings messagingFactorySettings = new MessagingFactorySettings();

            messagingFactorySettings.TransportType    = TransportType.NetMessaging;
            messagingFactorySettings.OperationTimeout = TimeSpan.FromMinutes(60);
            messagingFactorySettings.TokenProvider    = namespaceManager.Settings.TokenProvider;


            MessagingFactory messagingFactory = MessagingFactory.Create(namespaceManager.Address, messagingFactorySettings);

            _subscriptionClient = messagingFactory.CreateSubscriptionClient(topicName, subscriptionName, mode);
            if (prefetchCount.HasValue)
            {
                _subscriptionClient.PrefetchCount = prefetchCount.Value;
            }
        }