public ServiceBusConnectionContext(ServiceBusScaleoutConfiguration configuration,
                                           IList <string> topicNames,
                                           TraceSource traceSource,
                                           Action <int, IEnumerable <Microsoft.Azure.ServiceBus.Message> > handler,
                                           Action <int, Exception> errorHandler,
                                           Action <int> openStream)
        {
            if (topicNames == null)
            {
                throw new ArgumentNullException("topicNames");
            }

            _configuration = configuration;

            _subscriptions = new SubscriptionContext[topicNames.Count];
            _topicClients  = new TopicClient[topicNames.Count];

            _trace = traceSource;

            TopicNames   = topicNames;
            Handler      = handler;
            ErrorHandler = errorHandler;
            OpenStream   = openStream;

            SubscriptionsLock = new object();
        }
Example #2
0
        public ServiceBusConnection(ServiceBusScaleoutConfiguration configuration, TraceSource traceSource)
        {
            _trace            = traceSource;
            _connectionString = configuration.BuildConnectionString();

            _namespaceManager = new ManagementClient(_connectionString);
            //_factory = MessagingFactory.CreateFromConnectionString(_connectionString);

            //if (configuration.RetryPolicy != null)
            //{
            //    _factory.RetryPolicy = configuration.RetryPolicy;
            //}
            //else
            //{
            //    _factory.RetryPolicy = RetryExponential.Default;
            //}


            _backoffTime             = configuration.BackoffTime;
            _idleSubscriptionTimeout = configuration.IdleSubscriptionTimeout;
            _configuration           = configuration;
        }
Example #3
0
        public ServiceBusMessageBus(IDependencyResolver resolver, ServiceBusScaleoutConfiguration configuration)
            : base(resolver, configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            // Retrieve the trace manager
            var traceManager = resolver.Resolve <ITraceManager>();

            _trace = traceManager["SignalR." + nameof(ServiceBusMessageBus)];

            _connection = new ServiceBusConnection(configuration, _trace);

            _topics = Enumerable.Range(0, configuration.TopicCount)
                      .Select(topicIndex => SignalRTopicPrefix + "_" + configuration.TopicPrefix + "_" + topicIndex)
                      .ToArray();

            _connectionContext = new ServiceBusConnectionContext(configuration, _topics, _trace, OnMessage, OnError, Open);

            Subscribe().GetAwaiter().GetResult();
        }
        /// <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);
        }
        /// <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="connectionString">The Service Bus connection string to use.</param>
        /// <param name="topicPrefix">The topic prefix to use. Typically represents the app name. This must be consistent between all nodes in the web farm.</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, string connectionString, string topicPrefix)
        {
            var config = new ServiceBusScaleoutConfiguration(connectionString, topicPrefix);

            return(UseServiceBus(resolver, config));
        }