예제 #1
0
        /// <summary>
        /// Use Windows Azure Service Bus as the messaging backplane for scaling out of ASP.NET SignalR applications in a web farm.
        /// </summary>
        /// <param name="resolver">The dependency resolver.</param>
        /// <param name="configuration">The Service Bus scale-out configuration options.</param>
        /// <returns>The dependency resolver</returns>
        /// <remarks>Note: Only Windows Azure Service Bus is supported. Service Bus for Windows Server (on-premise) is not supported.</remarks>
        public static IDependencyResolver UseServiceBus(this IDependencyResolver resolver, ServiceBusScaleoutConfiguration configuration)
        {
            var bus = new ServiceBusMessageBus(resolver, configuration);

            resolver.Register(typeof(IMessageBus), () => bus);

            return(resolver);
        }
 public TopicSubscriptionConsumer(ServiceBusMessageBus messageBus, AbstractConsumerSettings consumerSettings, IMessageProcessor <Message> messageProcessor)
     : base(messageBus, consumerSettings,
            messageBus.ProviderSettings.SubscriptionClientFactory(new SubscriptionFactoryParams(consumerSettings.Topic, consumerSettings.GetSubscriptionName())),
            messageProcessor,
            messageBus.LoggerFactory.CreateLogger <TopicSubscriptionConsumer>())
 {
     _subscriptionClient = (SubscriptionClient)Client;
 }
예제 #3
0
 public QueueConsumer(ServiceBusMessageBus messageBus, AbstractConsumerSettings consumerSettings, IMessageProcessor <Message> messageProcessor)
     : base(messageBus, consumerSettings,
            messageBus.ServiceBusSettings.QueueClientFactory(consumerSettings.Topic),
            messageProcessor,
            LogManager.GetLogger <QueueConsumer>())
 {
     _queueClient = (IQueueClient)Client;
 }
예제 #4
0
 public QueueConsumer(ServiceBusMessageBus messageBus, AbstractConsumerSettings consumerSettings, IMessageProcessor <Message> messageProcessor)
     : base(messageBus ?? throw new ArgumentNullException(nameof(messageBus)),
            consumerSettings ?? throw new ArgumentNullException(nameof(consumerSettings)),
            messageBus.ProviderSettings.QueueClientFactory(consumerSettings.Topic),
            messageProcessor,
            LogManager.GetLogger <QueueConsumer>())
 {
     _queueClient = (IQueueClient)Client;
 }
        public ServiceBusMessagingTests()
        {
            if (!Settings.Current.UseAzureServiceBus)
            {
                return;
            }

            _messageBus = new ServiceBusMessageBus(Settings.Current.AzureServiceBusConnectionString, "test-messagebus");
        }
예제 #6
0
        public BaseConsumer(ServiceBusMessageBus messageBus, AbstractConsumerSettings consumerSettings, IReceiverClient client, IMessageProcessor <Message> messageProcessor, ILog log)
        {
            _log             = log;
            MessageBus       = messageBus ?? throw new ArgumentNullException(nameof(messageBus));
            ConsumerSettings = consumerSettings ?? throw new ArgumentNullException(nameof(consumerSettings));
            Client           = client ?? throw new ArgumentNullException(nameof(client));

            MessageProcessor = messageProcessor ?? throw new ArgumentNullException(nameof(messageProcessor));

            // Configure the message handler options in terms of exception handling, number of concurrent messages to deliver, etc.
            var messageHandlerOptions = new MessageHandlerOptions(ExceptionReceivedHandler)
            {
                // Maximum number of concurrent calls to the callback ProcessMessagesAsync(), set to 1 for simplicity.
                // Set it according to how many messages the application wants to process in parallel.
                MaxConcurrentCalls = consumerSettings.Instances,

                // Indicates whether the message pump should automatically complete the messages after returning from user callback.
                // False below indicates the complete operation is handled by the user callback as in ProcessMessagesAsync().
                AutoComplete = false
            };

            // Register the function that processes messages.
            Client.RegisterMessageHandler(ProcessMessagesAsync, messageHandlerOptions);
        }
        public ServiceBusMessagingTests() {
            if (!Settings.Current.UseAzureServiceBus)
                return;

            _messageBus = new ServiceBusMessageBus(Settings.Current.AzureServiceBusConnectionString, "test-messagebus");   
        }