Skip to content
Browse files

update to add a method BuildConnecitonString to include OperationTime…

…out in SB ConnecitonString
  • Loading branch information...
1 parent 5dfe5d1 commit 2f5bb91b445d4cd8bedf913972e7aae6b67636ec @Xiaohongt Xiaohongt committed
View
16 src/Microsoft.AspNet.SignalR.ServiceBus/ServiceBusConnection.cs
@@ -24,27 +24,25 @@ internal class ServiceBusConnection : IDisposable
private readonly NamespaceManager _namespaceManager;
private readonly MessagingFactory _factory;
private readonly ServiceBusScaleoutConfiguration _configuration;
+ private readonly string _connectionString;
private readonly TraceSource _trace;
public ServiceBusConnection(ServiceBusScaleoutConfiguration configuration, TraceSource traceSource)
{
_trace = traceSource;
+ _connectionString = configuration.BuildConnectionString();
try
{
- _namespaceManager = NamespaceManager.CreateFromConnectionString(configuration.ConnectionString);
- _factory = MessagingFactory.CreateFromConnectionString(configuration.ConnectionString);
+ _namespaceManager = NamespaceManager.CreateFromConnectionString(_connectionString);
+ _factory = MessagingFactory.CreateFromConnectionString(_connectionString);
_factory.RetryPolicy = RetryExponential.Default;
}
catch (ConfigurationErrorsException ex)
{
- _trace.TraceError("Invalid connection string '{0}': {1}", configuration.ConnectionString, ex.Message);
+ _trace.TraceError("Invalid connection string '{0}': {1}", _connectionString, ex.Message);
}
- if (configuration.OperationTimeout != null)
- {
- _factory.GetSettings().OperationTimeout = configuration.OperationTimeout.Value;
- }
_idleSubscriptionTimeout = configuration.IdleSubscriptionTimeout;
_configuration = configuration;
}
@@ -109,7 +107,7 @@ private void CreateTopic(ServiceBusConnectionContext connectionContext, int topi
}
// Create a client for this topic
- TopicClient topicClient = TopicClient.CreateFromConnectionString(_configuration.ConnectionString, topicName);
+ TopicClient topicClient = TopicClient.CreateFromConnectionString(_connectionString, topicName);
connectionContext.SetTopicClients(topicClient, topicIndex);
_trace.TraceInformation("Creation of a new topic client {0} completed successfully.", topicName);
@@ -357,7 +355,5 @@ public void OnMessage(IEnumerable<BrokeredMessage> messages)
ConnectionContext.Handler(TopicIndex, messages);
}
}
-
-
}
}
View
17 src/Microsoft.AspNet.SignalR.ServiceBus/ServiceBusScaleoutConfiguration.cs
@@ -2,6 +2,8 @@
using System;
using Microsoft.AspNet.SignalR.Messaging;
+using Microsoft.ServiceBus;
+using System.Diagnostics.CodeAnalysis;
namespace Microsoft.AspNet.SignalR
{
@@ -90,5 +92,20 @@ public int TopicCount
/// Default value is set to 256KB which is the maximum recommended size for Service Bus operations
/// </summary>
public int MaximumMessageSize { get; set; }
+
+ /// <summary>
+ /// Returns Service Bus connection string to use.
+ /// </summary>
+ public string BuildConnectionString()
+ {
+ if (OperationTimeout != null)
+ {
+ var connectionStringBuilder = new ServiceBusConnectionStringBuilder(ConnectionString);
+ connectionStringBuilder.OperationTimeout = OperationTimeout.Value;
+ return connectionStringBuilder.ToString();
+ }
+
+ return ConnectionString;
+ }
}
}

0 comments on commit 2f5bb91

Please sign in to comment.
Something went wrong with that request. Please try again.