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

Commit b9ae045

Browse files
authored
Release 3.1.1
Release 3.1.1
2 parents 6e336b9 + 1a742c5 commit b9ae045

16 files changed

+220
-71
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Microsoft. All rights reserved.
1+
// Copyright (c) Microsoft. All rights reserved.
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

44
namespace Microsoft.Azure.ServiceBus.Core
@@ -911,7 +911,7 @@ public override void RegisterPlugin(ServiceBusPlugin serviceBusPlugin)
911911
}
912912
if (this.RegisteredPlugins.Any(p => p.Name == serviceBusPlugin.Name))
913913
{
914-
throw new ArgumentException(nameof(serviceBusPlugin), Resources.PluginAlreadyRegistered.FormatForUser(nameof(serviceBusPlugin)));
914+
throw new ArgumentException(nameof(serviceBusPlugin), Resources.PluginAlreadyRegistered.FormatForUser(serviceBusPlugin.Name));
915915
}
916916
this.RegisteredPlugins.Add(serviceBusPlugin);
917917
}
@@ -1141,6 +1141,10 @@ protected virtual async Task<IList<Message>> OnReceiveDeferredMessageAsync(long[
11411141
}
11421142
amqpRequestMessage.Map[ManagementConstants.Properties.SequenceNumbers] = sequenceNumbers;
11431143
amqpRequestMessage.Map[ManagementConstants.Properties.ReceiverSettleMode] = (uint)(this.ReceiveMode == ReceiveMode.ReceiveAndDelete ? 0 : 1);
1144+
if (!string.IsNullOrWhiteSpace(this.SessionIdInternal))
1145+
{
1146+
amqpRequestMessage.Map[ManagementConstants.Properties.SessionId] = this.SessionIdInternal;
1147+
}
11441148

11451149
var response = await this.ExecuteRequestResponseAsync(amqpRequestMessage).ConfigureAwait(false);
11461150

@@ -1690,4 +1694,4 @@ Rejected GetRejectedOutcome(IDictionary<string, object> propertiesToModify, stri
16901694
return rejected;
16911695
}
16921696
}
1693-
}
1697+
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Microsoft. All rights reserved.
1+
// Copyright (c) Microsoft. All rights reserved.
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

44
namespace Microsoft.Azure.ServiceBus.Core
@@ -389,7 +389,7 @@ public override void RegisterPlugin(ServiceBusPlugin serviceBusPlugin)
389389

390390
if (this.RegisteredPlugins.Any(p => p.GetType() == serviceBusPlugin.GetType()))
391391
{
392-
throw new ArgumentException(nameof(serviceBusPlugin), Resources.PluginAlreadyRegistered.FormatForUser(nameof(serviceBusPlugin)));
392+
throw new ArgumentException(nameof(serviceBusPlugin), Resources.PluginAlreadyRegistered.FormatForUser(serviceBusPlugin.Name));
393393
}
394394
this.RegisteredPlugins.Add(serviceBusPlugin);
395395
}
@@ -765,4 +765,4 @@ ArraySegment<byte> GetNextDeliveryTag()
765765
return new ArraySegment<byte>(BitConverter.GetBytes(deliveryId));
766766
}
767767
}
768-
}
768+
}

src/Microsoft.Azure.ServiceBus/Filters/XmlObjectConvertor.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ internal class XmlObjectConvertor
1313
internal static object ParseValueObject(XElement element)
1414
{
1515
var prefix = element.GetPrefixOfNamespace(XNamespace.Get(ManagementClientConstants.XmlSchemaNs));
16+
if (string.IsNullOrWhiteSpace(prefix))
17+
{
18+
return element.Value;
19+
}
20+
1621
var type = element.Attribute(XName.Get("type", ManagementClientConstants.XmlSchemaInstanceNs)).Value;
1722
switch (type.Substring(prefix.Length + 1))
1823
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public override bool Equals(object obj)
5151

5252
public bool Equals(AuthorizationRules other)
5353
{
54-
if (other == null || this.Count != other.Count)
54+
if (ReferenceEquals(other, null) || this.Count != other.Count)
5555
{
5656
return false;
5757
}

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@ public virtual async Task<SubscriptionDescription> GetSubscriptionAsync(string t
247247
/// <exception cref="UnauthorizedAccessException">No sufficient permission to perform this operation. You should check to ensure that your <see cref="ManagementClient"/> has the correct <see cref="TokenProvider"/> credentials to perform this operation.</exception>
248248
/// <exception cref="ServerBusyException">The server is busy. You should wait before you retry the operation.</exception>
249249
/// <exception cref="ServiceBusException">An internal error or an unexpected exception occured.</exception>
250+
/// <remarks>Note - Only following data types are deserialized in Filters and Action parameters - string,int,long,bool,double,DateTime.
251+
/// Other data types would return its string value.</remarks>
250252
public virtual async Task<RuleDescription> GetRuleAsync(string topicPath, string subscriptionName, string ruleName, CancellationToken cancellationToken = default)
251253
{
252254
EntityNameHelper.CheckValidTopicName(topicPath);
@@ -436,7 +438,9 @@ public virtual async Task<IList<SubscriptionDescription>> GetSubscriptionsAsync(
436438
/// <exception cref="ServerBusyException">The server is busy. You should wait before you retry the operation.</exception>
437439
/// <exception cref="ServiceBusException">An internal error or an unexpected exception occured.</exception>
438440
/// <remarks>You can simulate pages of list of entities by manipulating <paramref name="count"/> and <paramref name="skip"/>.
439-
/// skip(0)+count(100) gives first 100 entities. skip(100)+count(100) gives the next 100 entities.</remarks>
441+
/// skip(0)+count(100) gives first 100 entities. skip(100)+count(100) gives the next 100 entities.
442+
/// Note - Only following data types are deserialized in Filters and Action parameters - string,int,long,bool,double,DateTime.
443+
/// Other data types would return its string value.</remarks>
440444
public virtual async Task<IList<RuleDescription>> GetRulesAsync(string topicPath, string subscriptionName, int count = 100, int skip = 0, CancellationToken cancellationToken = default)
441445
{
442446
EntityNameHelper.CheckValidTopicName(topicPath);
@@ -895,7 +899,7 @@ private static async Task<Exception> ValidateHttpResponse(HttpResponseMessage re
895899
return null;
896900
}
897901

898-
var exceptionMessage = await response.Content?.ReadAsStringAsync();
902+
var exceptionMessage = await (response.Content?.ReadAsStringAsync() ?? Task.FromResult(string.Empty));
899903
exceptionMessage = ParseDetailIfAvailable(exceptionMessage) ?? response.ReasonPhrase;
900904

901905
if (response.StatusCode == HttpStatusCode.Unauthorized)

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
namespace Microsoft.Azure.ServiceBus.Management
55
{
66
using System;
7+
using System.Collections.Generic;
78
using Microsoft.Azure.ServiceBus.Primitives;
89

910
/// <summary>
@@ -283,6 +284,12 @@ public string UserMetadata
283284
}
284285
}
285286

287+
/// <summary>
288+
/// List of properties that were retrieved using GetQueue but are not understood by this version of client is stored here.
289+
/// The list will be sent back when an already retrieved QueueDescription will be used in UpdateQueue call.
290+
/// </summary>
291+
internal List<object> UnknownProperties { get; set; }
292+
286293
public override int GetHashCode()
287294
{
288295
return this.Path?.GetHashCode() ?? base.GetHashCode();
@@ -294,14 +301,10 @@ public override bool Equals(object obj)
294301
return this.Equals(other);
295302
}
296303

297-
public bool Equals(QueueDescription other)
304+
public bool Equals(QueueDescription otherDescription)
298305
{
299-
if (other == null)
300-
{
301-
return false;
302-
}
303-
304-
if (this.Path.Equals(other.Path, StringComparison.OrdinalIgnoreCase)
306+
if (otherDescription is QueueDescription other
307+
&& this.Path.Equals(other.Path, StringComparison.OrdinalIgnoreCase)
305308
&& this.AutoDeleteOnIdle.Equals(other.AutoDeleteOnIdle)
306309
&& this.DefaultMessageTimeToLive.Equals(other.DefaultMessageTimeToLive)
307310
&& (!this.RequiresDuplicateDetection || this.DuplicateDetectionHistoryTimeWindow.Equals(other.DuplicateDetectionHistoryTimeWindow))

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

Lines changed: 46 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,39 @@ internal static class QueueDescriptionExtensions
1212
{
1313
public static XDocument Serialize(this QueueDescription description)
1414
{
15+
var queueDescriptionElements = new List<object>()
16+
{
17+
new XElement(XName.Get("LockDuration", ManagementClientConstants.SbNs), XmlConvert.ToString(description.LockDuration)),
18+
new XElement(XName.Get("MaxSizeInMegabytes", ManagementClientConstants.SbNs), XmlConvert.ToString(description.MaxSizeInMB)),
19+
new XElement(XName.Get("RequiresDuplicateDetection", ManagementClientConstants.SbNs), XmlConvert.ToString(description.RequiresDuplicateDetection)),
20+
new XElement(XName.Get("RequiresSession", ManagementClientConstants.SbNs), XmlConvert.ToString(description.RequiresSession)),
21+
description.DefaultMessageTimeToLive != TimeSpan.MaxValue ? new XElement(XName.Get("DefaultMessageTimeToLive", ManagementClientConstants.SbNs), XmlConvert.ToString(description.DefaultMessageTimeToLive)) : null,
22+
new XElement(XName.Get("DeadLetteringOnMessageExpiration", ManagementClientConstants.SbNs), XmlConvert.ToString(description.EnableDeadLetteringOnMessageExpiration)),
23+
description.RequiresDuplicateDetection && description.DuplicateDetectionHistoryTimeWindow != default ?
24+
new XElement(XName.Get("DuplicateDetectionHistoryTimeWindow", ManagementClientConstants.SbNs), XmlConvert.ToString(description.DuplicateDetectionHistoryTimeWindow))
25+
: null,
26+
new XElement(XName.Get("MaxDeliveryCount", ManagementClientConstants.SbNs), XmlConvert.ToString(description.MaxDeliveryCount)),
27+
new XElement(XName.Get("EnableBatchedOperations", ManagementClientConstants.SbNs), XmlConvert.ToString(description.EnableBatchedOperations)),
28+
description.AuthorizationRules?.Serialize(),
29+
new XElement(XName.Get("Status", ManagementClientConstants.SbNs), description.Status.ToString()),
30+
description.ForwardTo != null ? new XElement(XName.Get("ForwardTo", ManagementClientConstants.SbNs), description.ForwardTo) : null,
31+
description.UserMetadata != null ? new XElement(XName.Get("UserMetadata", ManagementClientConstants.SbNs), description.UserMetadata) : null,
32+
description.AutoDeleteOnIdle != TimeSpan.MaxValue ? new XElement(XName.Get("AutoDeleteOnIdle", ManagementClientConstants.SbNs), XmlConvert.ToString(description.AutoDeleteOnIdle)) : null,
33+
new XElement(XName.Get("EnablePartitioning", ManagementClientConstants.SbNs), XmlConvert.ToString(description.EnablePartitioning)),
34+
description.ForwardDeadLetteredMessagesTo != null ? new XElement(XName.Get("ForwardDeadLetteredMessagesTo", ManagementClientConstants.SbNs), description.ForwardDeadLetteredMessagesTo) : null
35+
};
36+
37+
if (description.UnknownProperties != null)
38+
{
39+
queueDescriptionElements.AddRange(description.UnknownProperties);
40+
}
41+
1542
return new XDocument(
1643
new XElement(XName.Get("entry", ManagementClientConstants.AtomNs),
1744
new XElement(XName.Get("content", ManagementClientConstants.AtomNs),
1845
new XAttribute("type", "application/xml"),
1946
new XElement(XName.Get("QueueDescription", ManagementClientConstants.SbNs),
20-
new XElement(XName.Get("LockDuration", ManagementClientConstants.SbNs), XmlConvert.ToString(description.LockDuration)),
21-
new XElement(XName.Get("MaxSizeInMegabytes", ManagementClientConstants.SbNs), XmlConvert.ToString(description.MaxSizeInMB)),
22-
new XElement(XName.Get("RequiresDuplicateDetection", ManagementClientConstants.SbNs), XmlConvert.ToString(description.RequiresDuplicateDetection)),
23-
new XElement(XName.Get("RequiresSession", ManagementClientConstants.SbNs), XmlConvert.ToString(description.RequiresSession)),
24-
description.DefaultMessageTimeToLive != TimeSpan.MaxValue ? new XElement(XName.Get("DefaultMessageTimeToLive", ManagementClientConstants.SbNs), XmlConvert.ToString(description.DefaultMessageTimeToLive)) : null,
25-
new XElement(XName.Get("DeadLetteringOnMessageExpiration", ManagementClientConstants.SbNs), XmlConvert.ToString(description.EnableDeadLetteringOnMessageExpiration)),
26-
description.RequiresDuplicateDetection && description.DuplicateDetectionHistoryTimeWindow != default ?
27-
new XElement(XName.Get("DuplicateDetectionHistoryTimeWindow", ManagementClientConstants.SbNs), XmlConvert.ToString(description.DuplicateDetectionHistoryTimeWindow))
28-
: null,
29-
new XElement(XName.Get("MaxDeliveryCount", ManagementClientConstants.SbNs), XmlConvert.ToString(description.MaxDeliveryCount)),
30-
new XElement(XName.Get("EnableBatchedOperations", ManagementClientConstants.SbNs), XmlConvert.ToString(description.EnableBatchedOperations)),
31-
description.AuthorizationRules?.Serialize(),
32-
new XElement(XName.Get("Status", ManagementClientConstants.SbNs), description.Status.ToString()),
33-
description.ForwardTo != null ? new XElement(XName.Get("ForwardTo", ManagementClientConstants.SbNs), description.ForwardTo) : null,
34-
description.UserMetadata != null ? new XElement(XName.Get("UserMetadata", ManagementClientConstants.SbNs), description.UserMetadata) : null,
35-
description.AutoDeleteOnIdle != TimeSpan.MaxValue ? new XElement(XName.Get("AutoDeleteOnIdle", ManagementClientConstants.SbNs), XmlConvert.ToString(description.AutoDeleteOnIdle)) : null,
36-
new XElement(XName.Get("EnablePartitioning", ManagementClientConstants.SbNs), XmlConvert.ToString(description.EnablePartitioning)),
37-
description.ForwardDeadLetteredMessagesTo != null ? new XElement(XName.Get("ForwardDeadLetteredMessagesTo", ManagementClientConstants.SbNs), description.ForwardDeadLetteredMessagesTo) : null
38-
))
39-
));
47+
queueDescriptionElements.ToArray()))));
4048
}
4149

4250
public static QueueDescription ParseFromContent(string xml)
@@ -131,6 +139,24 @@ private static QueueDescription ParseFromEntryElement(XElement xEntry)
131139
case "AuthorizationRules":
132140
qd.AuthorizationRules = AuthorizationRules.ParseFromXElement(element);
133141
break;
142+
case "AccessedAt":
143+
case "CreatedAt":
144+
case "MessageCount":
145+
case "SizeInBytes":
146+
case "UpdatedAt":
147+
case "CountDetails":
148+
// Ignore known properties
149+
// Do nothing
150+
break;
151+
default:
152+
// For unknown properties, keep them as-is for forward proof.
153+
if (qd.UnknownProperties == null)
154+
{
155+
qd.UnknownProperties = new List<object>();
156+
}
157+
158+
qd.UnknownProperties.Add(element);
159+
break;
134160
}
135161
}
136162

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
namespace Microsoft.Azure.ServiceBus.Management
55
{
66
using System;
7+
using System.Collections.Generic;
78
using Microsoft.Azure.ServiceBus.Primitives;
89

910
/// <summary>
@@ -248,6 +249,12 @@ public string UserMetadata
248249
}
249250
}
250251

252+
/// <summary>
253+
/// List of properties that were retrieved using GetSubscription but are not understood by this version of client is stored here.
254+
/// The list will be sent back when an already retrieved SubscriptionDescription will be used in UpdateSubscription call.
255+
/// </summary>
256+
internal List<object> UnknownProperties { get; set; }
257+
251258
internal RuleDescription DefaultRuleDescription { get; set; }
252259

253260
public override int GetHashCode()

0 commit comments

Comments
 (0)