Skip to content

Commit 95745b2

Browse files
Add EnablePartitioning to QueueProperties ctor; rename GetRawMessage (#17101)
* Add EnablePartitioning to QueueProperties ctor; rename GetRawMessage * Revert test change * Port ATOM fix * fix * PR fb
1 parent 53103ed commit 95745b2

28 files changed

+1123
-733
lines changed

sdk/servicebus/Azure.Messaging.ServiceBus/api/Azure.Messaging.ServiceBus.netstandard2.0.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public ServiceBusMessage(string body) { }
168168
public string Subject { get { throw null; } set { } }
169169
public System.TimeSpan TimeToLive { get { throw null; } set { } }
170170
public string To { get { throw null; } set { } }
171-
public Azure.Core.Amqp.AmqpAnnotatedMessage GetRawMessage() { throw null; }
171+
public Azure.Core.Amqp.AmqpAnnotatedMessage GetRawAmqpMessage() { throw null; }
172172
public override string ToString() { throw null; }
173173
}
174174
public sealed partial class ServiceBusMessageBatch : System.IDisposable
@@ -184,15 +184,15 @@ public void Dispose() { }
184184
public static partial class ServiceBusModelFactory
185185
{
186186
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
187-
public static Azure.Messaging.ServiceBus.Administration.QueueProperties QueueProperties(string name, System.TimeSpan lockDuration = default(System.TimeSpan), long maxSizeInMegabytes = (long)0, bool requiresDuplicateDetection = false, bool requiresSession = false, System.TimeSpan defaultMessageTimeToLive = default(System.TimeSpan), System.TimeSpan autoDeleteOnIdle = default(System.TimeSpan), bool deadLetteringOnMessageExpiration = false, System.TimeSpan duplicateDetectionHistoryTimeWindow = default(System.TimeSpan), int maxDeliveryCount = 0, bool enableBatchedOperations = false, Azure.Messaging.ServiceBus.Administration.EntityStatus status = default(Azure.Messaging.ServiceBus.Administration.EntityStatus), string forwardTo = null, string forwardDeadLetteredMessagesTo = null, string userMetadata = null) { throw null; }
187+
public static Azure.Messaging.ServiceBus.Administration.QueueProperties QueueProperties(string name, System.TimeSpan lockDuration = default(System.TimeSpan), long maxSizeInMegabytes = (long)0, bool requiresDuplicateDetection = false, bool requiresSession = false, System.TimeSpan defaultMessageTimeToLive = default(System.TimeSpan), System.TimeSpan autoDeleteOnIdle = default(System.TimeSpan), bool deadLetteringOnMessageExpiration = false, System.TimeSpan duplicateDetectionHistoryTimeWindow = default(System.TimeSpan), int maxDeliveryCount = 0, bool enableBatchedOperations = false, Azure.Messaging.ServiceBus.Administration.EntityStatus status = default(Azure.Messaging.ServiceBus.Administration.EntityStatus), string forwardTo = null, string forwardDeadLetteredMessagesTo = null, string userMetadata = null, bool enablePartitioning = false) { throw null; }
188188
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
189189
public static Azure.Messaging.ServiceBus.Administration.RuleProperties RuleProperties(string name, Azure.Messaging.ServiceBus.Administration.RuleFilter filter = null, Azure.Messaging.ServiceBus.Administration.RuleAction action = null) { throw null; }
190190
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
191191
public static Azure.Messaging.ServiceBus.ServiceBusReceivedMessage ServiceBusReceivedMessage(System.BinaryData body = null, string messageId = null, string partitionKey = null, string viaPartitionKey = null, string sessionId = null, string replyToSessionId = null, System.TimeSpan timeToLive = default(System.TimeSpan), string correlationId = null, string subject = null, string to = null, string contentType = null, string replyTo = null, System.DateTimeOffset scheduledEnqueueTime = default(System.DateTimeOffset), System.Collections.Generic.IDictionary<string, object> properties = null, System.Guid lockTokenGuid = default(System.Guid), int deliveryCount = 0, System.DateTimeOffset lockedUntil = default(System.DateTimeOffset), long sequenceNumber = (long)-1, string deadLetterSource = null, long enqueuedSequenceNumber = (long)0, System.DateTimeOffset enqueuedTime = default(System.DateTimeOffset)) { throw null; }
192192
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
193193
public static Azure.Messaging.ServiceBus.Administration.SubscriptionProperties SubscriptionProperties(string topicName, string subscriptionName, System.TimeSpan lockDuration = default(System.TimeSpan), bool requiresSession = false, System.TimeSpan defaultMessageTimeToLive = default(System.TimeSpan), System.TimeSpan autoDeleteOnIdle = default(System.TimeSpan), bool deadLetteringOnMessageExpiration = false, int maxDeliveryCount = 0, bool enableBatchedOperations = false, Azure.Messaging.ServiceBus.Administration.EntityStatus status = default(Azure.Messaging.ServiceBus.Administration.EntityStatus), string forwardTo = null, string forwardDeadLetteredMessagesTo = null, string userMetadata = null) { throw null; }
194194
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
195-
public static Azure.Messaging.ServiceBus.Administration.TopicProperties TopicProperties(string name, long maxSizeInMegabytes = (long)0, bool requiresDuplicateDetection = false, System.TimeSpan defaultMessageTimeToLive = default(System.TimeSpan), System.TimeSpan autoDeleteOnIdle = default(System.TimeSpan), System.TimeSpan duplicateDetectionHistoryTimeWindow = default(System.TimeSpan), bool enableBatchedOperations = false, Azure.Messaging.ServiceBus.Administration.EntityStatus status = default(Azure.Messaging.ServiceBus.Administration.EntityStatus)) { throw null; }
195+
public static Azure.Messaging.ServiceBus.Administration.TopicProperties TopicProperties(string name, long maxSizeInMegabytes = (long)0, bool requiresDuplicateDetection = false, System.TimeSpan defaultMessageTimeToLive = default(System.TimeSpan), System.TimeSpan autoDeleteOnIdle = default(System.TimeSpan), System.TimeSpan duplicateDetectionHistoryTimeWindow = default(System.TimeSpan), bool enableBatchedOperations = false, Azure.Messaging.ServiceBus.Administration.EntityStatus status = default(Azure.Messaging.ServiceBus.Administration.EntityStatus), bool enablePartitioning = false) { throw null; }
196196
}
197197
public partial class ServiceBusProcessor : System.IAsyncDisposable
198198
{
@@ -260,7 +260,7 @@ internal ServiceBusReceivedMessage() { }
260260
public string Subject { get { throw null; } }
261261
public System.TimeSpan TimeToLive { get { throw null; } }
262262
public string To { get { throw null; } }
263-
public Azure.Core.Amqp.AmqpAnnotatedMessage GetRawMessage() { throw null; }
263+
public Azure.Core.Amqp.AmqpAnnotatedMessage GetRawAmqpMessage() { throw null; }
264264
public override string ToString() { throw null; }
265265
}
266266
public enum ServiceBusReceiveMode

sdk/servicebus/Azure.Messaging.ServiceBus/src/Administration/QueueProperties.cs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
using System;
55
using System.Collections.Generic;
6+
using System.Xml;
7+
using System.Xml.Linq;
68
using Azure.Core;
79

810
namespace Azure.Messaging.ServiceBus.Administration
@@ -51,6 +53,7 @@ internal QueueProperties(CreateQueueOptions options)
5153
Status = options.Status;
5254
ForwardTo = options.ForwardTo;
5355
ForwardDeadLetteredMessagesTo = options.ForwardDeadLetteredMessagesTo;
56+
EnablePartitioning = options.EnablePartitioning;
5457
if (options.UserMetadata != null)
5558
{
5659
UserMetadata = options.UserMetadata;
@@ -286,11 +289,29 @@ public string UserMetadata
286289
}
287290
}
288291

292+
internal bool IsAnonymousAccessible { get; set; } = false;
293+
294+
internal bool SupportOrdering
295+
{
296+
get
297+
{
298+
return _internalSupportOrdering ?? !EnablePartitioning;
299+
}
300+
set
301+
{
302+
_internalSupportOrdering = value;
303+
}
304+
}
305+
306+
internal bool? _internalSupportOrdering = null;
307+
308+
internal bool EnableExpress { get; set; } = false;
309+
289310
/// <summary>
290311
/// List of properties that were retrieved using GetQueue but are not understood by this version of client is stored here.
291312
/// The list will be sent back when an already retrieved QueueDescription will be used in UpdateQueue call.
292313
/// </summary>
293-
internal List<object> UnknownProperties { get; set; }
314+
internal List<XElement> UnknownProperties { get; set; }
294315

295316
/// <summary>
296317
/// Returns a hash code for this instance.
@@ -326,6 +347,9 @@ public bool Equals(QueueProperties other)
326347
&& RequiresDuplicateDetection.Equals(otherDescription.RequiresDuplicateDetection)
327348
&& RequiresSession.Equals(otherDescription.RequiresSession)
328349
&& Status.Equals(otherDescription.Status)
350+
&& SupportOrdering.Equals(other.SupportOrdering)
351+
&& EnableExpress == other.EnableExpress
352+
&& IsAnonymousAccessible == other.IsAnonymousAccessible
329353
&& string.Equals(_userMetadata, otherDescription._userMetadata, StringComparison.OrdinalIgnoreCase)
330354
&& (AuthorizationRules != null && otherDescription.AuthorizationRules != null
331355
|| AuthorizationRules == null && otherDescription.AuthorizationRules == null)

sdk/servicebus/Azure.Messaging.ServiceBus/src/Administration/QueuePropertiesExtensions.cs

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ internal static class QueuePropertiesExtensions
1515
{
1616
public static XDocument Serialize(this QueueProperties description)
1717
{
18-
var queueDescriptionElements = new List<object>()
18+
var queueDescriptionElements = new List<XElement>()
1919
{
2020
new XElement(XName.Get("LockDuration", AdministrationClientConstants.ServiceBusNamespace), XmlConvert.ToString(description.LockDuration)),
2121
new XElement(XName.Get("MaxSizeInMegabytes", AdministrationClientConstants.ServiceBusNamespace), XmlConvert.ToString(description.MaxSizeInMegabytes)),
@@ -28,15 +28,20 @@ public static XDocument Serialize(this QueueProperties description)
2828
: null,
2929
new XElement(XName.Get("MaxDeliveryCount", AdministrationClientConstants.ServiceBusNamespace), XmlConvert.ToString(description.MaxDeliveryCount)),
3030
new XElement(XName.Get("EnableBatchedOperations", AdministrationClientConstants.ServiceBusNamespace), XmlConvert.ToString(description.EnableBatchedOperations)),
31+
new XElement(XName.Get("IsAnonymousAccessible", AdministrationClientConstants.ServiceBusNamespace), XmlConvert.ToString(description.IsAnonymousAccessible)),
3132
description.AuthorizationRules?.Serialize(),
3233
new XElement(XName.Get("Status", AdministrationClientConstants.ServiceBusNamespace), description.Status.ToString()),
3334
description.ForwardTo != null ? new XElement(XName.Get("ForwardTo", AdministrationClientConstants.ServiceBusNamespace), description.ForwardTo) : null,
3435
description.UserMetadata != null ? new XElement(XName.Get("UserMetadata", AdministrationClientConstants.ServiceBusNamespace), description.UserMetadata) : null,
36+
description._internalSupportOrdering.HasValue ? new XElement(XName.Get("SupportOrdering", AdministrationClientConstants.ServiceBusNamespace), XmlConvert.ToString(description._internalSupportOrdering.Value)) : null,
3537
description.AutoDeleteOnIdle != TimeSpan.MaxValue ? new XElement(XName.Get("AutoDeleteOnIdle", AdministrationClientConstants.ServiceBusNamespace), XmlConvert.ToString(description.AutoDeleteOnIdle)) : null,
3638
new XElement(XName.Get("EnablePartitioning", AdministrationClientConstants.ServiceBusNamespace), XmlConvert.ToString(description.EnablePartitioning)),
37-
description.ForwardDeadLetteredMessagesTo != null ? new XElement(XName.Get("ForwardDeadLetteredMessagesTo", AdministrationClientConstants.ServiceBusNamespace), description.ForwardDeadLetteredMessagesTo) : null
39+
description.ForwardDeadLetteredMessagesTo != null ? new XElement(XName.Get("ForwardDeadLetteredMessagesTo", AdministrationClientConstants.ServiceBusNamespace), description.ForwardDeadLetteredMessagesTo) : null,
40+
new XElement(XName.Get("EnableExpress", AdministrationClientConstants.ServiceBusNamespace), XmlConvert.ToString(description.EnableExpress))
3841
};
3942

43+
// Insert unknown properties in the exact order they were in the received xml.
44+
// Expectation is that servicebus will add any new elements only at the bottom of the xml tree.
4045
if (description.UnknownProperties != null)
4146
{
4247
queueDescriptionElements.AddRange(description.UnknownProperties);
@@ -50,9 +55,6 @@ public static XDocument Serialize(this QueueProperties description)
5055
queueDescriptionElements.ToArray()))));
5156
}
5257

53-
/// <summary>
54-
///
55-
/// </summary>
5658
public static async Task<QueueProperties> ParseResponseAsync(Response response, ClientDiagnostics diagnostics)
5759
{
5860
try
@@ -81,7 +83,6 @@ public static async Task<QueueProperties> ParseResponseAsync(Response response,
8183
private static async Task<QueueProperties> ParseFromEntryElementAsync(XElement xEntry, Response response, ClientDiagnostics diagnostics)
8284
{
8385
var name = xEntry.Element(XName.Get("title", AdministrationClientConstants.AtomNamespace)).Value;
84-
var properties = new QueueProperties(name);
8586

8687
var qdXml = xEntry.Element(XName.Get("content", AdministrationClientConstants.AtomNamespace))?
8788
.Element(XName.Get("QueueDescription", AdministrationClientConstants.ServiceBusNamespace));
@@ -94,10 +95,14 @@ private static async Task<QueueProperties> ParseFromEntryElementAsync(XElement x
9495
innerException: await diagnostics.CreateRequestFailedExceptionAsync(response).ConfigureAwait(false));
9596
}
9697

98+
var properties = new QueueProperties(name);
9799
foreach (var element in qdXml.Elements())
98100
{
99101
switch (element.Name.LocalName)
100102
{
103+
case "LockDuration":
104+
properties.LockDuration = XmlConvert.ToTimeSpan(element.Value);
105+
break;
101106
case "MaxSizeInMegabytes":
102107
properties.MaxSizeInMegabytes = int.Parse(element.Value, CultureInfo.InvariantCulture);
103108
break;
@@ -107,65 +112,73 @@ private static async Task<QueueProperties> ParseFromEntryElementAsync(XElement x
107112
case "RequiresSession":
108113
properties.RequiresSession = bool.Parse(element.Value);
109114
break;
115+
case "DefaultMessageTimeToLive":
116+
properties.DefaultMessageTimeToLive = XmlConvert.ToTimeSpan(element.Value);
117+
break;
110118
case "DeadLetteringOnMessageExpiration":
111119
properties.DeadLetteringOnMessageExpiration = bool.Parse(element.Value);
112120
break;
113121
case "DuplicateDetectionHistoryTimeWindow":
114122
properties.DuplicateDetectionHistoryTimeWindow = XmlConvert.ToTimeSpan(element.Value);
115123
break;
116-
case "LockDuration":
117-
properties.LockDuration = XmlConvert.ToTimeSpan(element.Value);
118-
break;
119-
case "DefaultMessageTimeToLive":
120-
properties.DefaultMessageTimeToLive = XmlConvert.ToTimeSpan(element.Value);
121-
break;
122124
case "MaxDeliveryCount":
123125
properties.MaxDeliveryCount = int.Parse(element.Value, CultureInfo.InvariantCulture);
124126
break;
125127
case "EnableBatchedOperations":
126128
properties.EnableBatchedOperations = bool.Parse(element.Value);
127129
break;
128-
case "Status":
129-
properties.Status = element.Value;
130-
break;
131-
case "AutoDeleteOnIdle":
132-
properties.AutoDeleteOnIdle = XmlConvert.ToTimeSpan(element.Value);
130+
case "IsAnonymousAccessible":
131+
properties.IsAnonymousAccessible = Boolean.Parse(element.Value);
133132
break;
134-
case "EnablePartitioning":
135-
properties.EnablePartitioning = bool.Parse(element.Value);
133+
case "AuthorizationRules":
134+
properties.AuthorizationRules = AuthorizationRules.ParseFromXElement(element);
136135
break;
137-
case "UserMetadata":
138-
properties.UserMetadata = element.Value;
136+
case "Status":
137+
properties.Status = element.Value;
139138
break;
140139
case "ForwardTo":
141140
if (!string.IsNullOrWhiteSpace(element.Value))
142141
{
143142
properties.ForwardTo = element.Value;
144143
}
145144
break;
145+
case "UserMetadata":
146+
properties.UserMetadata = element.Value;
147+
break;
148+
case "SupportOrdering":
149+
properties.SupportOrdering = Boolean.Parse(element.Value);
150+
break;
151+
case "AutoDeleteOnIdle":
152+
properties.AutoDeleteOnIdle = XmlConvert.ToTimeSpan(element.Value);
153+
break;
154+
case "EnablePartitioning":
155+
properties.EnablePartitioning = bool.Parse(element.Value);
156+
break;
146157
case "ForwardDeadLetteredMessagesTo":
147158
if (!string.IsNullOrWhiteSpace(element.Value))
148159
{
149160
properties.ForwardDeadLetteredMessagesTo = element.Value;
150161
}
151162
break;
152-
case "AuthorizationRules":
153-
properties.AuthorizationRules = AuthorizationRules.ParseFromXElement(element);
163+
case "EnableExpress":
164+
properties.EnableExpress = bool.Parse(element.Value);
154165
break;
155166
case "AccessedAt":
156167
case "CreatedAt":
157168
case "MessageCount":
158169
case "SizeInBytes":
159170
case "UpdatedAt":
160171
case "CountDetails":
172+
case "EntityAvailabilityStatus":
173+
case "SkippedUpdate":
161174
// Ignore known properties
162175
// Do nothing
163176
break;
164177
default:
165178
// For unknown properties, keep them as-is for forward proof.
166179
if (properties.UnknownProperties == null)
167180
{
168-
properties.UnknownProperties = new List<object>();
181+
properties.UnknownProperties = new List<XElement>();
169182
}
170183

171184
properties.UnknownProperties.Add(element);

sdk/servicebus/Azure.Messaging.ServiceBus/src/Administration/SubscriptionProperties.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using System;
55
using System.Collections.Generic;
6+
using System.Xml.Linq;
67
using Azure.Core;
78

89
namespace Azure.Messaging.ServiceBus.Administration
@@ -268,7 +269,7 @@ public string UserMetadata
268269
/// List of properties that were retrieved using GetSubscription but are not understood by this version of client is stored here.
269270
/// The list will be sent back when an already retrieved SubscriptionDescription will be used in UpdateSubscription call.
270271
/// </summary>
271-
internal List<object> UnknownProperties { get; set; }
272+
internal List<XElement> UnknownProperties { get; set; }
272273

273274
internal RuleProperties Rule { get; set; }
274275

0 commit comments

Comments
 (0)