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>();
            TraceSource trace        = traceManager["SignalR." + typeof(ServiceBusMessageBus).Name];

            _connection = new ServiceBusConnection(configuration, trace);

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

            _subscription = _connection.Subscribe(_topics, OnMessage, OnError);

            // Open the streams after creating the subscription
            for (int i = 0; i < configuration.TopicCount; i++)
            {
                Open(i);
            }
        }
        public ServiceBusConnection(ServiceBusScaleoutConfiguration configuration, TraceSource traceSource)
        {
            _trace = traceSource;
            _connectionString = configuration.BuildConnectionString();

            try
            {
                _namespaceManager = NamespaceManager.CreateFromConnectionString(_connectionString);
                _factory = MessagingFactory.CreateFromConnectionString(_connectionString);

                if (configuration.RetryPolicy != null)
                {
                    _factory.RetryPolicy = configuration.RetryPolicy;
                }
                else
                {
                    _factory.RetryPolicy = RetryExponential.Default;
                }
            }
            catch (ConfigurationErrorsException)
            {
                _trace.TraceError("The configured Service Bus connection string contains an invalid property. Check the exception details for more information.");
                throw;
            }

            _backoffTime = configuration.BackoffTime;
            _idleSubscriptionTimeout = configuration.IdleSubscriptionTimeout;    
            _configuration = configuration;
        }
Exemple #3
0
        public ServiceBusConnection(ServiceBusScaleoutConfiguration configuration, TraceSource traceSource)
        {
            _trace            = traceSource;
            _connectionString = configuration.BuildConnectionString();

            try
            {
                _namespaceManager = NamespaceManager.CreateFromConnectionString(_connectionString);
                _factory          = MessagingFactory.CreateFromConnectionString(_connectionString);

                if (configuration.RetryPolicy != null)
                {
                    _factory.RetryPolicy = configuration.RetryPolicy;
                }
                else
                {
                    _factory.RetryPolicy = RetryExponential.Default;
                }
            }
            catch (ConfigurationErrorsException)
            {
                _trace.TraceError("The configured Service Bus connection string contains an invalid property. Check the exception details for more information.");
                throw;
            }

            _backoffTime             = configuration.BackoffTime;
            _idleSubscriptionTimeout = configuration.IdleSubscriptionTimeout;
            _configuration           = configuration;
        }
        public void Configuration(IAppBuilder app)
        {
            var serviceBusScaleoutConfiguration = new ServiceBusScaleoutConfiguration(ConfigurationManager.ConnectionStrings["servicebus"].ConnectionString, "nancysignals")
            {
                BackoffTime = TimeSpan.FromSeconds(5)
            };

            var ioc              = new TinyIoCContainer();
            var bootstrapper     = new Bootstrapper(ioc);
            var hubConfiguration = new HubConfiguration
            {
                Resolver = bootstrapper.DependencyResolver
            };

            hubConfiguration.Resolver.UseServiceBus(serviceBusScaleoutConfiguration);
            var nancyOptions = new NancyOptions
            {
                Bootstrapper = bootstrapper
            };

            GlobalHost.DependencyResolver = bootstrapper.DependencyResolver;

            app.MapSignalR(hubConfiguration);
            app.UseNancy(nancyOptions);
        }
        protected override MessageBus CreateMessageBus()
        {
            var configuration = new ServiceBusScaleoutConfiguration(RunData.ServiceBusConnectionString, "Stress");
            // configuration.RetryOnError = true;

            return new ServiceBusMessageBus(Resolver, configuration);
        }
Exemple #6
0
        public ServiceBusConnectionContext(ServiceBusScaleoutConfiguration configuration,
                                           IList <string> topicNames,
                                           TraceSource traceSource,
                                           Action <int, IEnumerable <BrokeredMessage> > 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;

            TopicClientsLock  = new object();
            SubscriptionsLock = new object();
        }
        public ServiceBusConnectionContext(ServiceBusScaleoutConfiguration configuration,
                                           IList<string> topicNames,
                                           TraceSource traceSource,
                                           Action<int, IEnumerable<BrokeredMessage>> 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;

            TopicClientsLock = new object();
            SubscriptionsLock = new object();
        }
        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>();
            TraceSource trace = traceManager["SignalR." + typeof(ServiceBusMessageBus).Name];

            _connection = new ServiceBusConnection(configuration, trace);

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

            _subscription = _connection.Subscribe(_topics, OnMessage, OnError);

            // Open the streams after creating the subscription
            for (int i = 0; i < configuration.TopicCount; i++)
            {
                Open(i);
            }
        }
 public ServiceBusConnection(ServiceBusScaleoutConfiguration configuration, TraceSource traceSource)
 {
     _namespaceManager = NamespaceManager.CreateFromConnectionString(configuration.ConnectionString);
     _factory          = MessagingFactory.CreateFromConnectionString(configuration.ConnectionString);
     _configuration    = configuration;
     _trace            = traceSource;
 }
        protected override MessageBus CreateMessageBus()
        {
            var configuration = new ServiceBusScaleoutConfiguration(RunData.ServiceBusConnectionString, "Stress");

            // configuration.RetryOnError = true;

            return(new ServiceBusMessageBus(Resolver, configuration));
        }
 public ServiceBusSubscription(ServiceBusScaleoutConfiguration configuration,
                               NamespaceManager namespaceManager,
                               IList<SubscriptionContext> subscriptions,
                               IList<TopicClient> clients)
 {
     _configuration = configuration;
     _namespaceManager = namespaceManager;
     _subscriptions = subscriptions;
     _clients = clients;
 }
Exemple #12
0
 public ServiceBusSubscription(ServiceBusScaleoutConfiguration configuration,
                               NamespaceManager namespaceManager,
                               IList <SubscriptionContext> subscriptions,
                               IList <TopicClient> clients)
 {
     _configuration    = configuration;
     _namespaceManager = namespaceManager;
     _subscriptions    = subscriptions;
     _clients          = clients;
 }
Exemple #13
0
        private static void SetupSignalR(IJabbrConfiguration jabbrConfig, IKernel kernel, IAppBuilder app)
        {
            var resolver          = new NinjectSignalRDependencyResolver(kernel);
            var connectionManager = resolver.Resolve <IConnectionManager>();
            var heartbeat         = resolver.Resolve <ITransportHeartbeat>();
            var hubPipeline       = resolver.Resolve <IHubPipeline>();
            var configuration     = resolver.Resolve <IConfigurationManager>();

            // Enable service bus scale out
            if (!String.IsNullOrEmpty(jabbrConfig.ServiceBusConnectionString) &&
                !String.IsNullOrEmpty(jabbrConfig.ServiceBusTopicPrefix))
            {
                var sbConfig = new ServiceBusScaleoutConfiguration(jabbrConfig.ServiceBusConnectionString,
                                                                   jabbrConfig.ServiceBusTopicPrefix)
                {
                    TopicCount = 5
                };

                resolver.UseServiceBus(sbConfig);
            }

            if (jabbrConfig.ScaleOutSqlServer)
            {
                resolver.UseSqlServer(ConfigurationManager.ConnectionStrings["Jabbr"].ConnectionString);
            }

            kernel.Bind <IConnectionManager>()
            .ToConstant(connectionManager);

            // We need to extend this since the inital connect might take a while
            configuration.TransportConnectTimeout = TimeSpan.FromSeconds(30);

            var config = new HubConfiguration
            {
                Resolver = resolver
            };

            hubPipeline.AddModule(kernel.Get <LoggingHubPipelineModule>());

            app.MapSignalR(config);

            var monitor = new PresenceMonitor(kernel, connectionManager, heartbeat);

            monitor.Start();
        }
        public ServiceBusConnection(ServiceBusScaleoutConfiguration configuration, TraceSource traceSource)
        {
            _trace = traceSource;

            try
            {
                _namespaceManager = NamespaceManager.CreateFromConnectionString(configuration.ConnectionString);
            }
            catch (ConfigurationErrorsException ex)
            {
                _trace.TraceError("Invalid connection string '{0}': {1}", configuration.ConnectionString, ex.Message);

                throw;
            }

            _factory = MessagingFactory.CreateFromConnectionString(configuration.ConnectionString);
            _configuration = configuration;
        }
Exemple #15
0
        public ServiceBusConnection(ServiceBusScaleoutConfiguration configuration, TraceSource traceSource)
        {
            _trace = traceSource;

            try
            {
                _namespaceManager = NamespaceManager.CreateFromConnectionString(configuration.ConnectionString);
            }
            catch (ConfigurationErrorsException ex)
            {
                _trace.TraceError("Invalid connection string '{0}': {1}", configuration.ConnectionString, ex.Message);

                throw;
            }

            _factory       = MessagingFactory.CreateFromConnectionString(configuration.ConnectionString);
            _configuration = configuration;
        }
Exemple #16
0
        public void Configuration(IAppBuilder app)
        {
            var connectionString = "PUT YOUR CONNECTION STRING HERE";

            /* Example of connection string:
             *     "Endpoint=sb://someurl.servicebus.windows.net/;"
             + "SharedSecretIssuer=owner;"
             + "SharedSecretValue=I9gqKTXQxe2mdoMZ+5WPD6XQEn4Y3y+0/k9lFeMnt2o=";
             */

            var config = new ServiceBusScaleoutConfiguration(connectionString, "Broadcaster")
            {
                TimeToLive = TimeSpan.FromSeconds(5)
            };

            GlobalHost.DependencyResolver.UseServiceBus(config);
            app.MapSignalR();
        }
        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." + typeof(ServiceBusMessageBus).Name];

            _connection = new ServiceBusConnection(configuration, _trace);

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

            ThreadPool.QueueUserWorkItem(Subscribe);
        }
        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." + typeof(ServiceBusMessageBus).Name];

            _connection = new ServiceBusConnection(configuration, _trace);

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

            ThreadPool.QueueUserWorkItem(Subscribe);
        }
Exemple #19
0
        public ServiceBusMessageBus(IDependencyResolver resolver, ServiceBusScaleoutConfiguration configuration)
            : base(resolver, configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            _connection = new ServiceBusConnection(configuration);

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

            _subscription = _connection.Subscribe(_topics, OnMessage, OnError);

            // Open the streams after creating the subscription
            for (int i = 0; i < configuration.TopicCount; i++)
            {
                Open(i);
            }
        }
        public ServiceBusMessageBus(IDependencyResolver resolver, ServiceBusScaleoutConfiguration configuration)
            : base(resolver, configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            _connection = new ServiceBusConnection(configuration);

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

            _subscription = _connection.Subscribe(_topics, OnMessage, OnError);

            // Open the streams after creating the subscription
            for (int i = 0; i < configuration.TopicCount; i++)
            {
                Open(i);
            }
        }
Exemple #21
0
        public void PositiveTopicCountsWork()
        {
            var config = new ServiceBusScaleoutConfiguration("cs", "topic");

            config.TopicCount = 1;
        }
Exemple #22
0
        public void ValidateTopicCount(int topicCount)
        {
            var config = new ServiceBusScaleoutConfiguration("cs", "topic");

            Assert.Throws <ArgumentOutOfRangeException>(() => config.TopicCount = topicCount);
        }
 public void ValidateTopicCount(int topicCount)
 {
     var config = new ServiceBusScaleoutConfiguration("cs", "topic");
     Assert.Throws<ArgumentOutOfRangeException>(() => config.TopicCount = topicCount);
 }
 public void PositiveTopicCountsWork()
 {
     var config = new ServiceBusScaleoutConfiguration("cs", "topic");
     config.TopicCount = 1;
 }
 public ServiceBusConnection(ServiceBusScaleoutConfiguration configuration)
 {
     _namespaceManager = NamespaceManager.CreateFromConnectionString(configuration.ConnectionString);
     _factory = MessagingFactory.CreateFromConnectionString(configuration.ConnectionString);
     _configuration = configuration;
 }