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

Commit

Permalink
Release 3.1.1
Browse files Browse the repository at this point in the history
Release 3.1.1
  • Loading branch information
nemakam authored Sep 28, 2018
2 parents 6e336b9 + 1a742c5 commit b9ae045
Show file tree
Hide file tree
Showing 16 changed files with 220 additions and 71 deletions.
10 changes: 7 additions & 3 deletions src/Microsoft.Azure.ServiceBus/Core/MessageReceiver.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft. All rights reserved.
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace Microsoft.Azure.ServiceBus.Core
Expand Down Expand Up @@ -911,7 +911,7 @@ public override void RegisterPlugin(ServiceBusPlugin serviceBusPlugin)
}
if (this.RegisteredPlugins.Any(p => p.Name == serviceBusPlugin.Name))
{
throw new ArgumentException(nameof(serviceBusPlugin), Resources.PluginAlreadyRegistered.FormatForUser(nameof(serviceBusPlugin)));
throw new ArgumentException(nameof(serviceBusPlugin), Resources.PluginAlreadyRegistered.FormatForUser(serviceBusPlugin.Name));
}
this.RegisteredPlugins.Add(serviceBusPlugin);
}
Expand Down Expand Up @@ -1141,6 +1141,10 @@ protected virtual async Task<IList<Message>> OnReceiveDeferredMessageAsync(long[
}
amqpRequestMessage.Map[ManagementConstants.Properties.SequenceNumbers] = sequenceNumbers;
amqpRequestMessage.Map[ManagementConstants.Properties.ReceiverSettleMode] = (uint)(this.ReceiveMode == ReceiveMode.ReceiveAndDelete ? 0 : 1);
if (!string.IsNullOrWhiteSpace(this.SessionIdInternal))
{
amqpRequestMessage.Map[ManagementConstants.Properties.SessionId] = this.SessionIdInternal;
}

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

Expand Down Expand Up @@ -1690,4 +1694,4 @@ Rejected GetRejectedOutcome(IDictionary<string, object> propertiesToModify, stri
return rejected;
}
}
}
}
6 changes: 3 additions & 3 deletions src/Microsoft.Azure.ServiceBus/Core/MessageSender.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft. All rights reserved.
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

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

if (this.RegisteredPlugins.Any(p => p.GetType() == serviceBusPlugin.GetType()))
{
throw new ArgumentException(nameof(serviceBusPlugin), Resources.PluginAlreadyRegistered.FormatForUser(nameof(serviceBusPlugin)));
throw new ArgumentException(nameof(serviceBusPlugin), Resources.PluginAlreadyRegistered.FormatForUser(serviceBusPlugin.Name));
}
this.RegisteredPlugins.Add(serviceBusPlugin);
}
Expand Down Expand Up @@ -765,4 +765,4 @@ ArraySegment<byte> GetNextDeliveryTag()
return new ArraySegment<byte>(BitConverter.GetBytes(deliveryId));
}
}
}
}
5 changes: 5 additions & 0 deletions src/Microsoft.Azure.ServiceBus/Filters/XmlObjectConvertor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ internal class XmlObjectConvertor
internal static object ParseValueObject(XElement element)
{
var prefix = element.GetPrefixOfNamespace(XNamespace.Get(ManagementClientConstants.XmlSchemaNs));
if (string.IsNullOrWhiteSpace(prefix))
{
return element.Value;
}

var type = element.Attribute(XName.Get("type", ManagementClientConstants.XmlSchemaInstanceNs)).Value;
switch (type.Substring(prefix.Length + 1))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public override bool Equals(object obj)

public bool Equals(AuthorizationRules other)
{
if (other == null || this.Count != other.Count)
if (ReferenceEquals(other, null) || this.Count != other.Count)
{
return false;
}
Expand Down
8 changes: 6 additions & 2 deletions src/Microsoft.Azure.ServiceBus/Management/ManagementClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ public virtual async Task<SubscriptionDescription> GetSubscriptionAsync(string t
/// <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>
/// <exception cref="ServerBusyException">The server is busy. You should wait before you retry the operation.</exception>
/// <exception cref="ServiceBusException">An internal error or an unexpected exception occured.</exception>
/// <remarks>Note - Only following data types are deserialized in Filters and Action parameters - string,int,long,bool,double,DateTime.
/// Other data types would return its string value.</remarks>
public virtual async Task<RuleDescription> GetRuleAsync(string topicPath, string subscriptionName, string ruleName, CancellationToken cancellationToken = default)
{
EntityNameHelper.CheckValidTopicName(topicPath);
Expand Down Expand Up @@ -436,7 +438,9 @@ public virtual async Task<IList<SubscriptionDescription>> GetSubscriptionsAsync(
/// <exception cref="ServerBusyException">The server is busy. You should wait before you retry the operation.</exception>
/// <exception cref="ServiceBusException">An internal error or an unexpected exception occured.</exception>
/// <remarks>You can simulate pages of list of entities by manipulating <paramref name="count"/> and <paramref name="skip"/>.
/// skip(0)+count(100) gives first 100 entities. skip(100)+count(100) gives the next 100 entities.</remarks>
/// skip(0)+count(100) gives first 100 entities. skip(100)+count(100) gives the next 100 entities.
/// Note - Only following data types are deserialized in Filters and Action parameters - string,int,long,bool,double,DateTime.
/// Other data types would return its string value.</remarks>
public virtual async Task<IList<RuleDescription>> GetRulesAsync(string topicPath, string subscriptionName, int count = 100, int skip = 0, CancellationToken cancellationToken = default)
{
EntityNameHelper.CheckValidTopicName(topicPath);
Expand Down Expand Up @@ -895,7 +899,7 @@ private static async Task<Exception> ValidateHttpResponse(HttpResponseMessage re
return null;
}

var exceptionMessage = await response.Content?.ReadAsStringAsync();
var exceptionMessage = await (response.Content?.ReadAsStringAsync() ?? Task.FromResult(string.Empty));
exceptionMessage = ParseDetailIfAvailable(exceptionMessage) ?? response.ReasonPhrase;

if (response.StatusCode == HttpStatusCode.Unauthorized)
Expand Down
17 changes: 10 additions & 7 deletions src/Microsoft.Azure.ServiceBus/Management/QueueDescription.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
namespace Microsoft.Azure.ServiceBus.Management
{
using System;
using System.Collections.Generic;
using Microsoft.Azure.ServiceBus.Primitives;

/// <summary>
Expand Down Expand Up @@ -283,6 +284,12 @@ public string UserMetadata
}
}

/// <summary>
/// List of properties that were retrieved using GetQueue but are not understood by this version of client is stored here.
/// The list will be sent back when an already retrieved QueueDescription will be used in UpdateQueue call.
/// </summary>
internal List<object> UnknownProperties { get; set; }

public override int GetHashCode()
{
return this.Path?.GetHashCode() ?? base.GetHashCode();
Expand All @@ -294,14 +301,10 @@ public override bool Equals(object obj)
return this.Equals(other);
}

public bool Equals(QueueDescription other)
public bool Equals(QueueDescription otherDescription)
{
if (other == null)
{
return false;
}

if (this.Path.Equals(other.Path, StringComparison.OrdinalIgnoreCase)
if (otherDescription is QueueDescription other
&& this.Path.Equals(other.Path, StringComparison.OrdinalIgnoreCase)
&& this.AutoDeleteOnIdle.Equals(other.AutoDeleteOnIdle)
&& this.DefaultMessageTimeToLive.Equals(other.DefaultMessageTimeToLive)
&& (!this.RequiresDuplicateDetection || this.DuplicateDetectionHistoryTimeWindow.Equals(other.DuplicateDetectionHistoryTimeWindow))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,39 @@ internal static class QueueDescriptionExtensions
{
public static XDocument Serialize(this QueueDescription description)
{
var queueDescriptionElements = new List<object>()
{
new XElement(XName.Get("LockDuration", ManagementClientConstants.SbNs), XmlConvert.ToString(description.LockDuration)),
new XElement(XName.Get("MaxSizeInMegabytes", ManagementClientConstants.SbNs), XmlConvert.ToString(description.MaxSizeInMB)),
new XElement(XName.Get("RequiresDuplicateDetection", ManagementClientConstants.SbNs), XmlConvert.ToString(description.RequiresDuplicateDetection)),
new XElement(XName.Get("RequiresSession", ManagementClientConstants.SbNs), XmlConvert.ToString(description.RequiresSession)),
description.DefaultMessageTimeToLive != TimeSpan.MaxValue ? new XElement(XName.Get("DefaultMessageTimeToLive", ManagementClientConstants.SbNs), XmlConvert.ToString(description.DefaultMessageTimeToLive)) : null,
new XElement(XName.Get("DeadLetteringOnMessageExpiration", ManagementClientConstants.SbNs), XmlConvert.ToString(description.EnableDeadLetteringOnMessageExpiration)),
description.RequiresDuplicateDetection && description.DuplicateDetectionHistoryTimeWindow != default ?
new XElement(XName.Get("DuplicateDetectionHistoryTimeWindow", ManagementClientConstants.SbNs), XmlConvert.ToString(description.DuplicateDetectionHistoryTimeWindow))
: null,
new XElement(XName.Get("MaxDeliveryCount", ManagementClientConstants.SbNs), XmlConvert.ToString(description.MaxDeliveryCount)),
new XElement(XName.Get("EnableBatchedOperations", ManagementClientConstants.SbNs), XmlConvert.ToString(description.EnableBatchedOperations)),
description.AuthorizationRules?.Serialize(),
new XElement(XName.Get("Status", ManagementClientConstants.SbNs), description.Status.ToString()),
description.ForwardTo != null ? new XElement(XName.Get("ForwardTo", ManagementClientConstants.SbNs), description.ForwardTo) : null,
description.UserMetadata != null ? new XElement(XName.Get("UserMetadata", ManagementClientConstants.SbNs), description.UserMetadata) : null,
description.AutoDeleteOnIdle != TimeSpan.MaxValue ? new XElement(XName.Get("AutoDeleteOnIdle", ManagementClientConstants.SbNs), XmlConvert.ToString(description.AutoDeleteOnIdle)) : null,
new XElement(XName.Get("EnablePartitioning", ManagementClientConstants.SbNs), XmlConvert.ToString(description.EnablePartitioning)),
description.ForwardDeadLetteredMessagesTo != null ? new XElement(XName.Get("ForwardDeadLetteredMessagesTo", ManagementClientConstants.SbNs), description.ForwardDeadLetteredMessagesTo) : null
};

if (description.UnknownProperties != null)
{
queueDescriptionElements.AddRange(description.UnknownProperties);
}

return new XDocument(
new XElement(XName.Get("entry", ManagementClientConstants.AtomNs),
new XElement(XName.Get("content", ManagementClientConstants.AtomNs),
new XAttribute("type", "application/xml"),
new XElement(XName.Get("QueueDescription", ManagementClientConstants.SbNs),
new XElement(XName.Get("LockDuration", ManagementClientConstants.SbNs), XmlConvert.ToString(description.LockDuration)),
new XElement(XName.Get("MaxSizeInMegabytes", ManagementClientConstants.SbNs), XmlConvert.ToString(description.MaxSizeInMB)),
new XElement(XName.Get("RequiresDuplicateDetection", ManagementClientConstants.SbNs), XmlConvert.ToString(description.RequiresDuplicateDetection)),
new XElement(XName.Get("RequiresSession", ManagementClientConstants.SbNs), XmlConvert.ToString(description.RequiresSession)),
description.DefaultMessageTimeToLive != TimeSpan.MaxValue ? new XElement(XName.Get("DefaultMessageTimeToLive", ManagementClientConstants.SbNs), XmlConvert.ToString(description.DefaultMessageTimeToLive)) : null,
new XElement(XName.Get("DeadLetteringOnMessageExpiration", ManagementClientConstants.SbNs), XmlConvert.ToString(description.EnableDeadLetteringOnMessageExpiration)),
description.RequiresDuplicateDetection && description.DuplicateDetectionHistoryTimeWindow != default ?
new XElement(XName.Get("DuplicateDetectionHistoryTimeWindow", ManagementClientConstants.SbNs), XmlConvert.ToString(description.DuplicateDetectionHistoryTimeWindow))
: null,
new XElement(XName.Get("MaxDeliveryCount", ManagementClientConstants.SbNs), XmlConvert.ToString(description.MaxDeliveryCount)),
new XElement(XName.Get("EnableBatchedOperations", ManagementClientConstants.SbNs), XmlConvert.ToString(description.EnableBatchedOperations)),
description.AuthorizationRules?.Serialize(),
new XElement(XName.Get("Status", ManagementClientConstants.SbNs), description.Status.ToString()),
description.ForwardTo != null ? new XElement(XName.Get("ForwardTo", ManagementClientConstants.SbNs), description.ForwardTo) : null,
description.UserMetadata != null ? new XElement(XName.Get("UserMetadata", ManagementClientConstants.SbNs), description.UserMetadata) : null,
description.AutoDeleteOnIdle != TimeSpan.MaxValue ? new XElement(XName.Get("AutoDeleteOnIdle", ManagementClientConstants.SbNs), XmlConvert.ToString(description.AutoDeleteOnIdle)) : null,
new XElement(XName.Get("EnablePartitioning", ManagementClientConstants.SbNs), XmlConvert.ToString(description.EnablePartitioning)),
description.ForwardDeadLetteredMessagesTo != null ? new XElement(XName.Get("ForwardDeadLetteredMessagesTo", ManagementClientConstants.SbNs), description.ForwardDeadLetteredMessagesTo) : null
))
));
queueDescriptionElements.ToArray()))));
}

public static QueueDescription ParseFromContent(string xml)
Expand Down Expand Up @@ -131,6 +139,24 @@ private static QueueDescription ParseFromEntryElement(XElement xEntry)
case "AuthorizationRules":
qd.AuthorizationRules = AuthorizationRules.ParseFromXElement(element);
break;
case "AccessedAt":
case "CreatedAt":
case "MessageCount":
case "SizeInBytes":
case "UpdatedAt":
case "CountDetails":
// Ignore known properties
// Do nothing
break;
default:
// For unknown properties, keep them as-is for forward proof.
if (qd.UnknownProperties == null)
{
qd.UnknownProperties = new List<object>();
}

qd.UnknownProperties.Add(element);
break;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
namespace Microsoft.Azure.ServiceBus.Management
{
using System;
using System.Collections.Generic;
using Microsoft.Azure.ServiceBus.Primitives;

/// <summary>
Expand Down Expand Up @@ -248,6 +249,12 @@ public string UserMetadata
}
}

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

internal RuleDescription DefaultRuleDescription { get; set; }

public override int GetHashCode()
Expand Down
Loading

0 comments on commit b9ae045

Please sign in to comment.