| | | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | | 2 | | // Licensed under the MIT License. |
| | | 3 | | |
| | | 4 | | using System; |
| | | 5 | | using System.Collections.Generic; |
| | | 6 | | using System.Threading; |
| | | 7 | | using System.Threading.Tasks; |
| | | 8 | | using Azure.Messaging.EventHubs.Consumer; |
| | | 9 | | |
| | | 10 | | namespace Azure.Messaging.EventHubs.Core |
| | | 11 | | { |
| | | 12 | | /// <summary> |
| | | 13 | | /// Provides an abstraction for generalizing an Event Consumer so that a dedicated instance may provide operations |
| | | 14 | | /// for a specific transport, such as AMQP or JMS. It is intended that the public <see cref="EventHubConsumerClie |
| | | 15 | | /// a transport consumer via containment and delegate operations to it rather than understanding protocol-specific |
| | | 16 | | /// for different transports. |
| | | 17 | | /// </summary> |
| | | 18 | | /// |
| | | 19 | | internal abstract class TransportConsumer |
| | | 20 | | { |
| | | 21 | | /// <summary> |
| | | 22 | | /// Indicates whether or not this consumer has been closed. |
| | | 23 | | /// </summary> |
| | | 24 | | /// |
| | | 25 | | /// <value> |
| | | 26 | | /// <c>true</c> if the consumer is closed; otherwise, <c>false</c>. |
| | | 27 | | /// </value> |
| | | 28 | | /// |
| | 4 | 29 | | public virtual bool IsClosed { get; } |
| | | 30 | | |
| | | 31 | | /// <summary> |
| | | 32 | | /// The most recent event received from the Event Hubs service by this consumer instance. |
| | | 33 | | /// </summary> |
| | | 34 | | /// |
| | | 35 | | /// <value> |
| | | 36 | | /// <c>null</c>, if the tracking of the last enqueued event information was not requested; otherwise, |
| | | 37 | | /// the most recently received event. |
| | | 38 | | /// </value> |
| | | 39 | | /// |
| | 26 | 40 | | public EventData LastReceivedEvent { get; protected set; } |
| | | 41 | | |
| | | 42 | | /// <summary> |
| | | 43 | | /// Receives a batch of <see cref="EventData" /> from the Event Hub partition. |
| | | 44 | | /// </summary> |
| | | 45 | | /// |
| | | 46 | | /// <param name="maximumMessageCount">The maximum number of messages to receive in this batch.</param> |
| | | 47 | | /// <param name="maximumWaitTime">The maximum amount of time to wait to build up the requested message count for |
| | | 48 | | /// <param name="cancellationToken">An optional <see cref="CancellationToken"/> instance to signal the request t |
| | | 49 | | /// |
| | | 50 | | /// <returns>The batch of <see cref="EventData" /> from the Event Hub partition this consumer is associated with |
| | | 51 | | /// |
| | | 52 | | public abstract Task<IReadOnlyList<EventData>> ReceiveAsync(int maximumMessageCount, |
| | | 53 | | TimeSpan? maximumWaitTime, |
| | | 54 | | CancellationToken cancellationToken); |
| | | 55 | | |
| | | 56 | | /// <summary> |
| | | 57 | | /// Closes the connection to the transport producer instance. |
| | | 58 | | /// </summary> |
| | | 59 | | /// |
| | | 60 | | /// <param name="cancellationToken">An optional <see cref="CancellationToken"/> instance to signal the request t |
| | | 61 | | /// |
| | | 62 | | public abstract Task CloseAsync(CancellationToken cancellationToken); |
| | | 63 | | } |
| | | 64 | | } |