| | 1 | | // Copyright (c) Microsoft. All rights reserved. |
| | 2 | | // Licensed under the MIT license. See LICENSE file in the project root for full license information. |
| | 3 | |
|
| | 4 | | namespace Microsoft.Azure.ServiceBus.Core |
| | 5 | | { |
| | 6 | | using System.Threading.Tasks; |
| | 7 | |
|
| | 8 | | /// <summary> |
| | 9 | | /// This class provides methods that can be overridden to manipulate messages for custom plugin functionality. |
| | 10 | | /// </summary> |
| | 11 | | public abstract class ServiceBusPlugin |
| | 12 | | { |
| | 13 | | /// <summary> |
| | 14 | | /// Gets the name of the <see cref="ServiceBusPlugin"/>. |
| | 15 | | /// </summary> |
| | 16 | | /// <remarks>This name is used to identify the plugin, and prevent a plugin from being registered multiple times |
| | 17 | | public abstract string Name { get; } |
| | 18 | |
|
| | 19 | | /// <summary> |
| | 20 | | /// Determines whether or an exception in the plugin should prevent a send or receive operation. |
| | 21 | | /// </summary> |
| 0 | 22 | | public virtual bool ShouldContinueOnException => false; |
| | 23 | |
|
| | 24 | | /// <summary> |
| | 25 | | /// This operation is called before a message is sent. |
| | 26 | | /// </summary> |
| | 27 | | /// <param name="message">The <see cref="Message"/> to be modified by the plugin</param> |
| | 28 | | /// <returns>The modified <see cref="Message"/></returns> |
| | 29 | | public virtual Task<Message> BeforeMessageSend(Message message) |
| | 30 | | { |
| 0 | 31 | | return Task.FromResult(message); |
| | 32 | | } |
| | 33 | |
|
| | 34 | | /// <summary> |
| | 35 | | /// This operation is called after a message is received, but before it is returned to the <see cref="IMessageRe |
| | 36 | | /// </summary> |
| | 37 | | /// <param name="message">The <see cref="Message"/> to be modified by the plugin</param> |
| | 38 | | /// <returns>The modified <see cref="Message"/></returns> |
| | 39 | | public virtual Task<Message> AfterMessageReceive(Message message) |
| | 40 | | { |
| 0 | 41 | | return Task.FromResult(message); |
| | 42 | | } |
| | 43 | | } |
| | 44 | | } |