-
Notifications
You must be signed in to change notification settings - Fork 355
/
ServiceBusConfiguration.cs
91 lines (82 loc) · 2.89 KB
/
ServiceBusConfiguration.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
82
83
84
85
86
87
88
89
90
91
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using System;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Azure.ServiceBus;
using System.Threading.Tasks;
namespace Microsoft.Azure.WebJobs.ServiceBus
{
/// <summary>
/// Configuration options for the ServiceBus extension.
/// </summary>
public class ServiceBusConfiguration
{
private bool _connectionStringSet;
private string _connectionString;
private MessagingProvider _messagingProvider;
/// <summary>
/// Constructs a new instance.
/// </summary>
public ServiceBusConfiguration()
{
// We do not want to log MessageReceiverPump exceptions so just complete task in the git exception handler
Func<ExceptionReceivedEventArgs, Task> exceptionReceivedHandler = (args) => { return Task.CompletedTask; };
MessageOptions = new MessageHandlerOptions(exceptionReceivedHandler)
{
MaxConcurrentCalls = 16
};
}
/// <summary>
/// Gets or sets the Azure ServiceBus connection string.
/// </summary>
public string ConnectionString
{
get
{
if (!_connectionStringSet)
{
_connectionString = AmbientConnectionStringProvider.Instance.GetConnectionString(ConnectionStringNames.ServiceBus);
_connectionStringSet = true;
}
return _connectionString;
}
set
{
_connectionString = value;
_connectionStringSet = true;
}
}
/// <summary>
/// Gets or sets the default <see cref="MessageHandlerOptions"/> that will be used by
/// <see cref="MessageReceiver"/>s.
/// </summary>
public MessageHandlerOptions MessageOptions { get; set; }
/// <summary>
/// Gets or sets the default PrefetchCount that will be used by <see cref="MessageReceiver"/>s.
/// </summary>
public int PrefetchCount { get; set; }
/// <summary>
/// Gets or sets the <see cref="MessagingProvider"/> that will be used to create
/// instances used for message processing.
/// </summary>
public MessagingProvider MessagingProvider
{
get
{
if (_messagingProvider == null)
{
_messagingProvider = new MessagingProvider(this);
}
return _messagingProvider;
}
set
{
if (value == null)
{
throw new ArgumentNullException("value");
}
_messagingProvider = value;
}
}
}
}