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 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 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(); _connectionContext = new ServiceBusConnectionContext(configuration, _topics, _trace, OnMessage, OnError, Open); ThreadPool.QueueUserWorkItem(Subscribe); }
/// <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)); }