/// <summary> /// <para> /// Abandon the Azure Service Bus message on Azure while providing <paramref name="newMessageProperties"/> for properties that has to be modified in the process. /// </para> /// <para> /// This will make the message available again for immediate processing as the lock of the message will be released. /// </para> /// </summary> /// <param name="newMessageProperties">The properties to modify on the message during the abandoning of the message.</param> /// <exception cref="InvalidOperationException">Thrown when the message handler was not initialized yet.</exception> protected async Task AbandonMessageAsync(IDictionary <string, object> newMessageProperties = null) { if (EventArgs is null) { throw new InvalidOperationException( "Cannot abandon the Azure Service Bus message because the message handler running Azure Service Bus-specific operations was not yet initialized correctly"); } Logger.LogTrace("Abandoning message '{MessageId}'...", EventArgs.Message.MessageId); await EventArgs.AbandonMessageAsync(EventArgs.Message, newMessageProperties, EventArgs.CancellationToken); Logger.LogTrace("Message '{MessageId}' is abandoned using lock token!", EventArgs.Message.MessageId); }
/// <summary> /// Abandon the Azure Service Bus <paramref name="message"/> on Azure while providing <paramref name="newMessageProperties"/> for properties that has to be modified in the process. /// </summary> /// <param name="message">The message that has to be abandoned.</param> /// <param name="newMessageProperties">The properties to modify on the message during the abandoning of the message.</param> /// <exception cref="ArgumentNullException">Thrown when the <paramref name="message"/> is <c>null</c>.</exception> /// <exception cref="InvalidOperationException">Thrown when the message handler was not initialized yet.</exception> protected async Task AbandonAsync(ServiceBusReceivedMessage message, IDictionary <string, object> newMessageProperties = null) { Guard.NotNull(message, nameof(message), "Requires a message to be abandoned"); if (EventArgs is null) { throw new InvalidOperationException( "Cannot abandon the Azure Service Bus message because the message handler running Azure Service Bus-specific operations was not yet initialized correctly"); } Logger.LogTrace("Abandoning message '{MessageId}'...", message.MessageId); await EventArgs.AbandonMessageAsync(message, newMessageProperties, EventArgs.CancellationToken); Logger.LogTrace("Message '{MessageId}' is abandoned!", message.MessageId); }