/
ServiceBusScaleoutConfiguration.cs
81 lines (70 loc) · 2.72 KB
/
ServiceBusScaleoutConfiguration.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
using System;
using Microsoft.AspNet.SignalR.Messaging;
namespace Microsoft.AspNet.SignalR
{
/// <summary>
/// Settings for the Service Bus scale-out message bus implementation.
/// </summary>
public class ServiceBusScaleoutConfiguration : ScaleoutConfiguration
{
private int _topicCount;
public ServiceBusScaleoutConfiguration(string connectionString, string topicPrefix)
{
if (String.IsNullOrEmpty(connectionString))
{
throw new ArgumentNullException("connectionString");
}
if (String.IsNullOrEmpty(topicPrefix))
{
throw new ArgumentNullException("topicPrefix");
}
IdleSubscriptionTimeout = TimeSpan.FromHours(1);
ConnectionString = connectionString;
TopicPrefix = topicPrefix;
TopicCount = 1;
TimeToLive = TimeSpan.FromMinutes(1);
}
/// <summary>
/// The Service Bus connection string to use.
/// </summary>
public string ConnectionString { get; private set; }
/// <summary>
/// The topic prefix to use. Typically represents the app name.
/// This must be consistent between all nodes in the web farm.
/// </summary>
public string TopicPrefix { get; private set; }
/// <summary>
/// The number of topics to send messages over. Using more topics reduces contention and may increase throughput.
/// This must be consistent between all nodes in the web farm.
/// Defaults to 1.
/// </summary>
public int TopicCount
{
get
{
return _topicCount;
}
set
{
if (value < 1)
{
throw new ArgumentOutOfRangeException("value");
}
_topicCount = value;
}
}
/// <summary>
/// Gets or sets the message’s time to live value. This is the duration after
/// which the message expires, starting from when the message is sent to the
/// Service Bus. Messages older than their TimeToLive value will expire and no
/// longer be retained in the message store. Subscribers will be unable to receive
/// expired messages.
/// </summary>
public TimeSpan TimeToLive { get; set; }
/// <summary>
/// Specifies the time duration after which an idle subscription is deleted
/// </summary>
public TimeSpan IdleSubscriptionTimeout { get; set; }
}
}