| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System.Collections.Generic; |
| | 5 | | using System.Threading; |
| | 6 | | using System.Threading.Tasks; |
| | 7 | | using Microsoft.Azure.Amqp; |
| | 8 | |
|
| | 9 | | namespace Azure.Messaging.ServiceBus.Core |
| | 10 | | { |
| | 11 | | /// <summary> |
| | 12 | | /// Provides an abstraction for generalizing an Service Bus entity Producer so that a dedicated instance may provi |
| | 13 | | /// for a specific transport, such as AMQP or JMS. It is intended that the public <see cref="ServiceBusSender" /> |
| | 14 | | /// a transport producer via containment and delegate operations to it rather than understanding protocol-specific |
| | 15 | | /// for different transports. |
| | 16 | | /// </summary> |
| | 17 | | /// |
| | 18 | | internal abstract class TransportSender |
| | 19 | | { |
| | 20 | | /// <summary> |
| | 21 | | /// Indicates whether or not this producer has been closed. |
| | 22 | | /// </summary> |
| | 23 | | /// |
| | 24 | | /// <value> |
| | 25 | | /// <c>true</c> if the producer is closed; otherwise, <c>false</c>. |
| | 26 | | /// </value> |
| | 27 | | /// |
| 0 | 28 | | public virtual bool IsClosed { get; } |
| | 29 | |
|
| | 30 | | /// <summary> |
| | 31 | | /// Creates a size-constraint batch to which <see cref="ServiceBusMessage" /> may be added using a try-based p |
| | 32 | | /// exceed the maximum allowable size of the batch, the batch will not allow adding the message and signal tha |
| | 33 | | /// return value. |
| | 34 | | /// |
| | 35 | | /// Because messages that would violate the size constraint cannot be added, publishing a batch will not trigg |
| | 36 | | /// attempting to send the message to the Queue/Topic. |
| | 37 | | /// </summary> |
| | 38 | | /// |
| | 39 | | /// <param name="options">The set of options to consider when creating this batch.</param> |
| | 40 | | /// <param name="cancellationToken">An optional <see cref="CancellationToken"/> instance to signal the request t |
| | 41 | | /// |
| | 42 | | /// <returns>An <see cref="ServiceBusMessageBatch" /> with the requested <paramref name="options"/>.</returns> |
| | 43 | | /// |
| | 44 | | /// <seealso cref="CreateMessageBatchAsync(CreateMessageBatchOptions, CancellationToken)" /> |
| | 45 | | /// |
| | 46 | | public abstract ValueTask<TransportMessageBatch> CreateMessageBatchAsync( |
| | 47 | | CreateMessageBatchOptions options, |
| | 48 | | CancellationToken cancellationToken); |
| | 49 | |
|
| | 50 | | /// <summary> |
| | 51 | | /// Sends a list of messages to the associated Service Bus entity using a batched approach. |
| | 52 | | /// If the size of the messages exceed the maximum size of a single batch, |
| | 53 | | /// an exception will be triggered and the send will fail. In order to ensure that the messages |
| | 54 | | /// being sent will fit in a batch, use <see cref="SendBatchAsync"/> instead. |
| | 55 | | /// </summary> |
| | 56 | | /// |
| | 57 | | /// <param name="messages">The list of messages to send.</param> |
| | 58 | | /// <param name="cancellationToken">An optional <see cref="CancellationToken"/> instance to signal the request t |
| | 59 | | public abstract Task SendAsync( |
| | 60 | | IList<ServiceBusMessage> messages, |
| | 61 | | CancellationToken cancellationToken); |
| | 62 | |
|
| | 63 | | /// <summary> |
| | 64 | | /// Sends a <see cref="ServiceBusMessageBatch"/> to the associated Queue/Topic. |
| | 65 | | /// </summary> |
| | 66 | | /// |
| | 67 | | /// <param name="messageBatch">The set of messages to send.</param> |
| | 68 | | /// <param name="cancellationToken">An optional <see cref="CancellationToken"/> instance to signal the request t |
| | 69 | | /// |
| | 70 | | /// <returns>A task to be resolved on when the operation has completed.</returns> |
| | 71 | | /// |
| | 72 | | public abstract Task SendBatchAsync( |
| | 73 | | ServiceBusMessageBatch messageBatch, |
| | 74 | | CancellationToken cancellationToken); |
| | 75 | |
|
| | 76 | | /// <summary> |
| | 77 | | /// |
| | 78 | | /// </summary> |
| | 79 | | /// <param name="messages"></param> |
| | 80 | | /// <param name="cancellationToken"></param> |
| | 81 | | /// <returns></returns> |
| | 82 | | public abstract Task<long[]> ScheduleMessagesAsync( |
| | 83 | | IList<ServiceBusMessage> messages, |
| | 84 | | CancellationToken cancellationToken = default); |
| | 85 | |
|
| | 86 | | /// <summary> |
| | 87 | | /// |
| | 88 | | /// </summary> |
| | 89 | | /// <param name="sequenceNumbers"></param> |
| | 90 | | /// <param name="cancellationToken"></param> |
| | 91 | | /// <returns></returns> |
| | 92 | | public abstract Task CancelScheduledMessagesAsync( |
| | 93 | | long[] sequenceNumbers, |
| | 94 | | CancellationToken cancellationToken = default); |
| | 95 | |
|
| | 96 | | /// <summary> |
| | 97 | | /// Closes the connection to the transport producer instance. |
| | 98 | | /// </summary> |
| | 99 | | /// |
| | 100 | | /// <param name="cancellationToken">An optional <see cref="CancellationToken"/> instance to signal the request t |
| | 101 | | /// |
| | 102 | | public abstract Task CloseAsync(CancellationToken cancellationToken); |
| | 103 | | } |
| | 104 | | } |