Skip to content
This repository was archived by the owner on Oct 12, 2023. It is now read-only.

Commit ff1093d

Browse files
authored
Merge pull request #669 from Azure/release-3.4.0
Release 3.4.0
2 parents e3b417d + 41551d7 commit ff1093d

16 files changed

+205
-25
lines changed

.github/ISSUE_TEMPLATE.md renamed to .github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
---
2+
name: Bug report
3+
about: Report a bug to help us improve
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
111
## Actual Behavior
212
1.
313
2.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Is your feature request related to a problem? Please describe.**
11+
12+
A clear and concise description of what the problem is. E.g. “I’m always frustrated when [...]
13+
14+
**Describe the solution you’d like**
15+
16+
A clear and concise description of what you want to happen.
17+
18+
**Describe alternatives you’ve considered**
19+
20+
A clear and concise description of any alternative solutions or features you’ve considered.
21+
22+
**Additional context**
23+
24+
Add any other context or screenshots about the feature request here.

src/Microsoft.Azure.ServiceBus/Amqp/AmqpConnectionHelper.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
namespace Microsoft.Azure.ServiceBus.Amqp
55
{
66
using System;
7+
using System.Net;
78
using Microsoft.Azure.Amqp;
89
using Microsoft.Azure.Amqp.Sasl;
910
using Microsoft.Azure.Amqp.Transport;
@@ -101,7 +102,8 @@ public static TransportSettings CreateTcpTransportSettings(
101102
public static TransportSettings CreateWebSocketTransportSettings(
102103
string networkHost,
103104
string hostName,
104-
int port)
105+
int port,
106+
IWebProxy proxy)
105107
{
106108
var uriBuilder = new UriBuilder(
107109
WebSocketConstants.WebSocketSecureScheme,
@@ -112,7 +114,8 @@ public static TransportSettings CreateWebSocketTransportSettings(
112114
{
113115
Uri = uriBuilder.Uri,
114116
ReceiveBufferSize = AmqpConstants.TransportBufferSize,
115-
SendBufferSize = AmqpConstants.TransportBufferSize
117+
SendBufferSize = AmqpConstants.TransportBufferSize,
118+
Proxy = proxy
116119
};
117120

118121
TransportSettings tpSettings = webSocketTransportSettings;

src/Microsoft.Azure.ServiceBus/Core/MessageSender.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,11 @@ public async Task SendAsync(IList<Message> messageList)
237237
this.ThrowIfClosed();
238238

239239
var count = MessageSender.ValidateMessages(messageList);
240+
if (count <= 0)
241+
{
242+
return;
243+
}
244+
240245
MessagingEventSource.Log.MessageSendStart(this.ClientId, count);
241246

242247
bool isDiagnosticSourceEnabled = ServiceBusDiagnosticSource.IsEnabled();

src/Microsoft.Azure.ServiceBus/Management/ManagementClient.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ public class ManagementClient
1818
private HttpClient httpClient;
1919
private readonly string endpointFQDN;
2020
private readonly ITokenProvider tokenProvider;
21-
private readonly TimeSpan operationTimeout;
2221
private readonly int port;
2322
private readonly string clientId;
2423

@@ -48,14 +47,13 @@ public ManagementClient(string endpoint, ITokenProvider tokenProvider)
4847
/// <param name="tokenProvider">Token provider which will generate security tokens for authorization.</param>
4948
public ManagementClient(ServiceBusConnectionStringBuilder connectionStringBuilder, ITokenProvider tokenProvider = default)
5049
{
51-
this.httpClient = new HttpClient();
50+
this.httpClient = new HttpClient { Timeout = connectionStringBuilder.OperationTimeout };
5251
this.endpointFQDN = connectionStringBuilder.Endpoint;
5352
this.tokenProvider = tokenProvider ?? CreateTokenProvider(connectionStringBuilder);
54-
this.operationTimeout = Constants.DefaultOperationTimeout;
5553
this.port = GetPort(connectionStringBuilder.Endpoint);
5654
this.clientId = nameof(ManagementClient) + Guid.NewGuid().ToString("N").Substring(0, 6);
5755

58-
MessagingEventSource.Log.ManagementClientCreated(this.clientId, this.operationTimeout.TotalSeconds, this.tokenProvider.ToString());
56+
MessagingEventSource.Log.ManagementClientCreated(this.clientId, this.httpClient.Timeout.TotalSeconds, this.tokenProvider.ToString());
5957
}
6058

6159
public static HttpRequestMessage CloneRequest(HttpRequestMessage req)

src/Microsoft.Azure.ServiceBus/Management/NamespaceInfoExtensions.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,19 @@ private static NamespaceInfo ParseFromEntryElement(XElement xEntry)
5757
case "Alias":
5858
nsInfo.Alias = element.Value;
5959
break;
60+
case "MessagingUnits":
61+
int.TryParse(element.Value, out var units);
62+
nsInfo.MessagingUnits = units;
63+
break;
6064
case "NamespaceType":
6165
if (Enum.TryParse<NamespaceType>(element.Value, out var nsType))
6266
{
6367
nsInfo.NamespaceType = nsType;
6468
}
69+
else if (element.Value == "Messaging") // TODO: workaround till next major as it's a breaking change
70+
{
71+
nsInfo.NamespaceType = NamespaceType.ServiceBus;
72+
}
6573
else
6674
{
6775
nsInfo.NamespaceType = NamespaceType.Others;

src/Microsoft.Azure.ServiceBus/Management/NamespaceType.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public enum NamespaceType
1515

1616
/// <summary>
1717
/// Supported only for backward compatibility.
18-
/// Namespace can contain mixture of messaging entities and notification hubs.
18+
/// Namespace can contain mixture of messaging entities and notification hubs.
1919
/// </summary>
2020
Mixed = 2,
2121

src/Microsoft.Azure.ServiceBus/Message.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ public TimeSpan TimeToLive
268268
/// <summary>
269269
/// Gets the total size of the message body in bytes.
270270
/// </summary>
271-
public long Size => Body.Length;
271+
public long Size => this.Body != null ? this.Body.Length : 0;
272272

273273
/// <summary>
274274
/// Gets the "user properties" bag, which can be used for custom message metadata.

src/Microsoft.Azure.ServiceBus/Microsoft.Azure.ServiceBus.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@
2323
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
2424
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
2525
<GenerateDocumentationFile>true</GenerateDocumentationFile>
26-
<NoWarn>CS1591;CS1573</NoWarn>
26+
<NoWarn>CS1591;CS1573;NU5125</NoWarn>
2727
</PropertyGroup>
2828

2929
<ItemGroup>
30-
<PackageReference Include="Microsoft.Azure.Amqp" Version="[2.3.7, 3.0.0)" />
30+
<PackageReference Include="Microsoft.Azure.Amqp" Version="[2.4.1, 3.0.0)" />
3131
<PackageReference Include="Microsoft.Azure.Services.AppAuthentication" Version="[1.0.1, 2.0.0)" />
3232
<PackageReference Include="Microsoft.IdentityModel.Clients.ActiveDirectory" Version="[3.17.2, 5.0.0)" />
33-
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.4.1" />
33+
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.5.1" />
3434
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="[5.2.2, 6.0.0)" />
3535
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-18618-05" PrivateAssets="All" />
3636
</ItemGroup>

src/Microsoft.Azure.ServiceBus/ServiceBusConnection.cs

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
namespace Microsoft.Azure.ServiceBus
55
{
66
using System;
7+
using System.Net;
78
using System.Threading.Tasks;
89
using Microsoft.Azure.Amqp;
910
using Microsoft.Azure.Amqp.Framing;
@@ -37,19 +38,43 @@ public ServiceBusConnection(ServiceBusConnectionStringBuilder connectionStringBu
3738
/// <param name="namespaceConnectionString">Namespace connection string</param>
3839
/// <remarks>It is the responsibility of the user to close the connection after use through <see cref="CloseAsync"/></remarks>
3940
public ServiceBusConnection(string namespaceConnectionString)
40-
: this(namespaceConnectionString, Constants.DefaultOperationTimeout, RetryPolicy.Default)
41+
: this(namespaceConnectionString, RetryPolicy.Default)
4142
{
4243
}
4344

45+
/// <summary>
46+
/// Creates a new connection to service bus.
47+
/// </summary>
48+
/// <param name="namespaceConnectionString">Namespace connection string.</param>
49+
/// <param name="retryPolicy">Retry policy for operations. Defaults to <see cref="RetryPolicy.Default"/></param>
50+
/// <remarks>It is the responsibility of the user to close the connection after use through <see cref="CloseAsync"/></remarks>
51+
public ServiceBusConnection(string namespaceConnectionString, RetryPolicy retryPolicy = null)
52+
: this(retryPolicy)
53+
{
54+
if (string.IsNullOrWhiteSpace(namespaceConnectionString))
55+
{
56+
throw Fx.Exception.ArgumentNullOrWhiteSpace(nameof(namespaceConnectionString));
57+
}
58+
59+
var serviceBusConnectionStringBuilder = new ServiceBusConnectionStringBuilder(namespaceConnectionString);
60+
if (!string.IsNullOrWhiteSpace(serviceBusConnectionStringBuilder.EntityPath))
61+
{
62+
throw Fx.Exception.Argument(nameof(namespaceConnectionString), "NamespaceConnectionString should not contain EntityPath.");
63+
}
64+
65+
this.InitializeConnection(serviceBusConnectionStringBuilder);
66+
}
67+
4468
/// <summary>
4569
/// Creates a new connection to service bus.
4670
/// </summary>
4771
/// <param name="namespaceConnectionString">Namespace connection string.</param>
4872
/// <param name="operationTimeout">Duration after which individual operations will timeout.</param>
4973
/// <param name="retryPolicy">Retry policy for operations. Defaults to <see cref="RetryPolicy.Default"/></param>
5074
/// <remarks>It is the responsibility of the user to close the connection after use through <see cref="CloseAsync"/></remarks>
75+
[Obsolete("This constructor is obsolete. Use ServiceBusConnection(string namespaceConnectionString, RetryPolicy retryPolicy) constructor instead, providing operationTimeout in the connection string.")]
5176
public ServiceBusConnection(string namespaceConnectionString, TimeSpan operationTimeout, RetryPolicy retryPolicy = null)
52-
: this(operationTimeout, retryPolicy)
77+
: this(retryPolicy)
5378
{
5479
if (string.IsNullOrWhiteSpace(namespaceConnectionString))
5580
{
@@ -63,6 +88,8 @@ public ServiceBusConnection(string namespaceConnectionString, TimeSpan operation
6388
}
6489

6590
this.InitializeConnection(serviceBusConnectionStringBuilder);
91+
// operationTimeout argument explicitly provided by caller should take precedence over OperationTimeout found in the connection string.
92+
this.OperationTimeout = operationTimeout;
6693
}
6794

6895
/// <summary>
@@ -72,7 +99,7 @@ public ServiceBusConnection(string namespaceConnectionString, TimeSpan operation
7299
/// <param name="transportType">Transport type.</param>
73100
/// <param name="retryPolicy">Retry policy for operations. Defaults to <see cref="RetryPolicy.Default"/></param>
74101
public ServiceBusConnection(string endpoint, TransportType transportType, RetryPolicy retryPolicy = null)
75-
: this(Constants.DefaultOperationTimeout, retryPolicy)
102+
: this(retryPolicy)
76103
{
77104
if (string.IsNullOrWhiteSpace(endpoint))
78105
{
@@ -88,9 +115,8 @@ public ServiceBusConnection(string endpoint, TransportType transportType, RetryP
88115
this.InitializeConnection(serviceBusConnectionStringBuilder);
89116
}
90117

91-
internal ServiceBusConnection(TimeSpan operationTimeout, RetryPolicy retryPolicy = null)
118+
internal ServiceBusConnection(RetryPolicy retryPolicy = null)
92119
{
93-
this.OperationTimeout = operationTimeout;
94120
this.RetryPolicy = retryPolicy ?? RetryPolicy.Default;
95121
this.syncLock = new object();
96122
}
@@ -193,6 +219,7 @@ void InitializeConnection(ServiceBusConnectionStringBuilder builder)
193219
this.TokenProvider = new SharedAccessSignatureTokenProvider(builder.SasKeyName, builder.SasKey);
194220
}
195221

222+
this.OperationTimeout = builder.OperationTimeout;
196223
this.TransportType = builder.TransportType;
197224
this.ConnectionManager = new FaultTolerantAmqpObject<AmqpConnection>(this.CreateConnectionAsync, CloseConnection);
198225
this.TransactionController = new FaultTolerantAmqpObject<Controller>(this.CreateControllerAsync, CloseController);
@@ -283,7 +310,8 @@ TransportSettings CreateTransportSettings()
283310
return AmqpConnectionHelper.CreateWebSocketTransportSettings(
284311
networkHost: networkHost,
285312
hostName: hostName,
286-
port: port);
313+
port: port,
314+
proxy: WebRequest.DefaultWebProxy);
287315
}
288316

289317
return AmqpConnectionHelper.CreateTcpTransportSettings(

0 commit comments

Comments
 (0)