Skip to content

Commit

Permalink
Add SubQueue option and remove locktoken overloads (#14692)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshLove-msft authored Aug 31, 2020
1 parent 5fa0036 commit 902a8d8
Show file tree
Hide file tree
Showing 12 changed files with 138 additions and 102 deletions.
5 changes: 4 additions & 1 deletion sdk/servicebus/Azure.Messaging.ServiceBus/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,10 @@ ServiceBusReceivedMessage receivedMessage = await receiver.ReceiveMessageAsync()
await receiver.DeadLetterMessageAsync(receivedMessage);

// receive the dead lettered message with receiver scoped to the dead letter queue.
ServiceBusReceiver dlqReceiver = client.CreateDeadLetterReceiver(queueName);
ServiceBusReceiver dlqReceiver = client.CreateReceiver(queueName, new ServiceBusReceiverOptions
{
SubQueue = SubQueue.DeadLetter
});
ServiceBusReceivedMessage dlqMessage = await dlqReceiver.ReceiveMessageAsync();
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@ public CreateMessageBatchOptions() { }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public override string ToString() { throw null; }
}
public static partial class EntityNameFormatter
{
public static string FormatDeadLetterPath(string entityPath) { throw null; }
public static string FormatRulePath(string topicPath, string subscriptionName, string ruleName) { throw null; }
public static string FormatSubQueuePath(string entityPath, string subQueueName) { throw null; }
public static string FormatSubscriptionPath(string topicPath, string subscriptionName) { throw null; }
public static string FormatTransferDeadLetterPath(string entityPath) { throw null; }
}
public sealed partial class ProcessErrorEventArgs : System.EventArgs
{
public ProcessErrorEventArgs(System.Exception exception, Azure.Messaging.ServiceBus.ServiceBusErrorSource errorSource, string fullyQualifiedNamespace, string entityPath) { }
Expand Down Expand Up @@ -77,8 +69,6 @@ public ServiceBusClient(string connectionString, Azure.Messaging.ServiceBus.Serv
public string FullyQualifiedNamespace { get { throw null; } }
public bool IsDisposed { get { throw null; } }
public Azure.Messaging.ServiceBus.ServiceBusTransportType TransportType { get { throw null; } }
public virtual Azure.Messaging.ServiceBus.ServiceBusReceiver CreateDeadLetterReceiver(string queueName, Azure.Messaging.ServiceBus.ServiceBusReceiverOptions options = null) { throw null; }
public virtual Azure.Messaging.ServiceBus.ServiceBusReceiver CreateDeadLetterReceiver(string topicName, string subscriptionName, Azure.Messaging.ServiceBus.ServiceBusReceiverOptions options = null) { throw null; }
public virtual Azure.Messaging.ServiceBus.ServiceBusProcessor CreateProcessor(string queueName) { throw null; }
public virtual Azure.Messaging.ServiceBus.ServiceBusProcessor CreateProcessor(string queueName, Azure.Messaging.ServiceBus.ServiceBusProcessorOptions options) { throw null; }
public virtual Azure.Messaging.ServiceBus.ServiceBusProcessor CreateProcessor(string topicName, string subscriptionName) { throw null; }
Expand Down Expand Up @@ -262,15 +252,10 @@ protected ServiceBusReceiver() { }
public int PrefetchCount { get { throw null; } }
public Azure.Messaging.ServiceBus.ReceiveMode ReceiveMode { get { throw null; } }
public virtual System.Threading.Tasks.Task AbandonMessageAsync(Azure.Messaging.ServiceBus.ServiceBusReceivedMessage message, System.Collections.Generic.IDictionary<string, object> propertiesToModify = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task AbandonMessageAsync(string lockToken, System.Collections.Generic.IDictionary<string, object> propertiesToModify = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task CompleteMessageAsync(Azure.Messaging.ServiceBus.ServiceBusReceivedMessage message, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task CompleteMessageAsync(string lockToken, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task DeadLetterMessageAsync(Azure.Messaging.ServiceBus.ServiceBusReceivedMessage message, System.Collections.Generic.IDictionary<string, object> propertiesToModify = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task DeadLetterMessageAsync(Azure.Messaging.ServiceBus.ServiceBusReceivedMessage message, string deadLetterReason, string deadLetterErrorDescription = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task DeadLetterMessageAsync(string lockToken, System.Collections.Generic.IDictionary<string, object> propertiesToModify = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task DeadLetterMessageAsync(string lockToken, string deadLetterReason, string deadLetterErrorDescription = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task DeferMessageAsync(Azure.Messaging.ServiceBus.ServiceBusReceivedMessage message, System.Collections.Generic.IDictionary<string, object> propertiesToModify = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task DeferMessageAsync(string lockToken, System.Collections.Generic.IDictionary<string, object> propertiesToModify = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.ValueTask DisposeAsync() { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public override bool Equals(object obj) { throw null; }
Expand All @@ -284,7 +269,6 @@ protected ServiceBusReceiver() { }
public virtual System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<Azure.Messaging.ServiceBus.ServiceBusReceivedMessage>> ReceiveMessagesAsync(int maxMessages, System.TimeSpan? maxWaitTime = default(System.TimeSpan?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Collections.Generic.IAsyncEnumerable<Azure.Messaging.ServiceBus.ServiceBusReceivedMessage> ReceiveMessagesAsync([System.Runtime.CompilerServices.EnumeratorCancellationAttribute] System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task RenewMessageLockAsync(Azure.Messaging.ServiceBus.ServiceBusReceivedMessage message, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<System.DateTimeOffset> RenewMessageLockAsync(string lockToken, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public override string ToString() { throw null; }
}
Expand All @@ -293,6 +277,7 @@ public partial class ServiceBusReceiverOptions
public ServiceBusReceiverOptions() { }
public int PrefetchCount { get { throw null; } set { } }
public Azure.Messaging.ServiceBus.ReceiveMode ReceiveMode { get { throw null; } set { } }
public Azure.Messaging.ServiceBus.SubQueue SubQueue { get { throw null; } set { } }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public override bool Equals(object obj) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
Expand Down Expand Up @@ -433,6 +418,12 @@ public enum ServiceBusTransportType
AmqpTcp = 0,
AmqpWebSockets = 1,
}
public enum SubQueue
{
None = 0,
DeadLetter = 1,
TransferDeadLetter = 2,
}
}
namespace Azure.Messaging.ServiceBus.Management
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ ServiceBusReceivedMessage receivedMessage = await receiver.ReceiveMessageAsync()
await receiver.DeadLetterMessageAsync(receivedMessage);

// receive the dead lettered message with receiver scoped to the dead letter queue.
ServiceBusReceiver dlqReceiver = client.CreateDeadLetterReceiver(queueName);
ServiceBusReceiver dlqReceiver = client.CreateReceiver(queueName, new ServiceBusReceiverOptions
{
SubQueue = SubQueue.DeadLetter
});
ServiceBusReceivedMessage dlqMessage = await dlqReceiver.ReceiveMessageAsync();
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,63 +384,6 @@ public virtual async Task<ServiceBusSessionReceiver> CreateSessionReceiverAsync(
cancellationToken: cancellationToken).ConfigureAwait(false);
}

/// <summary>
/// Creates a <see cref="ServiceBusReceiver"/> instance that can be used for receiving from the
/// dead letter queue for the specified queue. It uses <see cref="ReceiveMode"/> to specify
/// how messages are received. Defaults to PeekLock mode. The <see cref="ReceiveMode"/> is set in <see cref="ServiceBusReceiverOptions"/>.
/// </summary>
///
/// <param name="queueName">The queue to create a <see cref="ServiceBusReceiver"/> for.</param>
/// <param name="options">The set of <see cref="ServiceBusReceiverOptions"/> to use for configuring the
/// <see cref="ServiceBusReceiver"/>.</param>
///
/// <returns>A <see cref="ServiceBusReceiver"/> scoped to the dead letter queue of the specified
/// queue.</returns>
public virtual ServiceBusReceiver CreateDeadLetterReceiver(
string queueName,
ServiceBusReceiverOptions options = default)
{
ValidateEntityName(queueName);

return new ServiceBusReceiver(
connection: Connection,
entityPath: EntityNameFormatter.FormatDeadLetterPath(queueName),
isSessionEntity: false,
plugins: Plugins,
options: options);
}

/// <summary>
/// Creates a <see cref="ServiceBusReceiver"/> instance that can be used for receiving from the
/// dead letter queue for the specified subscription. It uses <see cref="ReceiveMode"/> to specify
/// how messages are received. Defaults to PeekLock mode. The <see cref="ReceiveMode"/> is set in <see cref="ServiceBusReceiverOptions"/>.
/// </summary>
///
/// <param name="topicName">The topic to create a <see cref="ServiceBusReceiver"/> for.</param>
/// <param name="subscriptionName">The subscription to create a <see cref="ServiceBusReceiver"/> for.</param>
/// <param name="options">The set of <see cref="ServiceBusReceiverOptions"/> to use for configuring the
/// <see cref="ServiceBusReceiver"/>.</param>
///
/// <returns>A <see cref="ServiceBusReceiver"/> scoped to the dead letter queue of the specified
/// queue.</returns>
public virtual ServiceBusReceiver CreateDeadLetterReceiver(
string topicName,
string subscriptionName,
ServiceBusReceiverOptions options = default)
{
ValidateEntityName(topicName);

return new ServiceBusReceiver(
connection: Connection,
entityPath: EntityNameFormatter.FormatDeadLetterPath(
EntityNameFormatter.FormatSubscriptionPath(
topicName,
subscriptionName)),
isSessionEntity: false,
plugins: Plugins,
options: options);
}

/// <summary>
/// Creates a <see cref="ServiceBusProcessor"/> instance that can be used to process messages using
/// event handlers that are set on the processor. It uses <see cref="ReceiveMode"/> to specify
Expand Down Expand Up @@ -631,8 +574,7 @@ private void ValidateEntityName(string entityName)
/// Validates that the specified entity name matches the entity path in the Connection,
/// if an entity path is specified in the connection.
/// </summary>
/// <param name="entityName">Entity name to validate</param>
///
/// <param name="entityName">Entity name to validate.</param>
/// <param name="sendViaEntityName">The send via entity name to validate</param>
private void ValidateSendViaEntityName(string entityName, string sendViaEntityName)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Azure.Messaging.ServiceBus
/// <summary>
/// This class can be used to format the path for different Service Bus entity types.
/// </summary>
public static class EntityNameFormatter
internal static class EntityNameFormatter
{
private const string PathDelimiter = @"/";
private const string SubscriptionsSubPath = "Subscriptions";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

namespace Azure.Messaging.ServiceBus
{
/// <summary>
/// Represents the possible system subqueues that can be received from.
/// </summary>
public enum SubQueue
{
/// <summary>
/// No subqueue, the queue itself will be received from.
/// </summary>
None = 0,

/// <summary>
/// The dead-letter subqueue contains messages that have been deadlettered.
/// <see href="https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-dead-letter-queues#moving-messages-to-the-dlq"/>
/// </summary>
DeadLetter = 1,

/// <summary>
/// The transfer dead-letter subqueue contains messages that have been deadlettered when
/// the following conditions apply:
/// <list type="bullet">
/// <item>
/// <description>A message passes through more than four queues or topics that are chained together.</description>
/// </item>
/// <item>
/// <description>The destination queue or topic is disabled or deleted.</description>
/// </item>
/// <item>
/// <description>The destination queue or topic exceeds the maximum entity size.</description>
/// </item>
/// </list>
/// <seealso href="https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-dead-letter-queues#dead-lettering-in-forwardto-or-sendvia-scenarios"/>
/// </summary>
TransferDeadLetter = 2
}
}
Loading

0 comments on commit 902a8d8

Please sign in to comment.