Class EventHubReceiver
- Namespace
- Microsoft.ServiceBus.Messaging
- Assembly
- Microsoft.ServiceBus.dll
A client class used in receive operations related to an Event Hub consumer group. Represents a logical receiver connection to a specific Event Hub partition within a consumer group.
public sealed class EventHubReceiver : ClientEntity
- Inheritance
-
EventHubReceiver
- Inherited Members
Properties
Epoch
Gets the epoch value that is used to determine partition ownership during the receive operation.
public long? Epoch { get; }
Property Value
EventHubPath
Gets the event hub path.
public string EventHubPath { get; }
Property Value
- string
The event hub path.
Name
Gets the name of the Event Hub.
public string Name { get; }
Property Value
- string
The name of the Event Hub.
OffsetInclusive
Gets a value indicating whether StartingOffset is treated as an inclusive offset, meaning that the first event returned is the event that contains the starting offset. Normally, the first event returned is the event after the starting offset.
public bool OffsetInclusive { get; }
Property Value
PartitionId
Gets the partition ID for a logical partition of an Event Hub.
public string PartitionId { get; }
Property Value
- string
The partition identifier.
PrefetchCount
Gets or sets the number of events that any receive operation will actively cache. By default, this value is inherited from EventHubConsumerGroup. The default value is 10,000.
public int PrefetchCount { get; set; }
Property Value
- int
The number of messages that the message receiver can simultaneously request.
Exceptions
- ArgumentOutOfRangeException
Thrown if the value is less than the minimum required value of 10.
PrefetchSizeInBytes
public long? PrefetchSizeInBytes { get; set; }
Property Value
- long?
StartingDateTimeUtc
Gets the starting date and time in UTC format for this receiver. The Receive method starts receiving the next event after this StartingDateTimeUtc value. If null, the receiver starts receiving events from the beginning of the Event Hubs event stream.
public DateTime? StartingDateTimeUtc { get; }
Property Value
- DateTime?
The starting date and time in UTC.
StartingOffset
Gets the starting offset for this receiver. The Receive method starts receiving the next event after this offset value. If the value is null, the receiver starts receiving events from the beginning of the Event Hubs event stream.
public string StartingOffset { get; }
Property Value
- string
The starting offset.
Methods
OnAbort()
protected override void OnAbort()
OnBeginClose(TimeSpan, AsyncCallback, object)
protected override IAsyncResult OnBeginClose(TimeSpan timeout, AsyncCallback callback, object state)
Parameters
timeout
TimeSpancallback
AsyncCallbackstate
object
Returns
- IAsyncResult
Returns IAsyncResult.
OnBeginOpen(TimeSpan, AsyncCallback, object)
protected override IAsyncResult OnBeginOpen(TimeSpan timeout, AsyncCallback callback, object state)
Parameters
timeout
TimeSpancallback
AsyncCallbackstate
object
Returns
- IAsyncResult
Returns IAsyncResult.
OnClose(TimeSpan)
protected override void OnClose(TimeSpan timeout)
Parameters
timeout
TimeSpan
OnEndClose(IAsyncResult)
protected override void OnEndClose(IAsyncResult result)
Parameters
result
IAsyncResult
OnEndOpen(IAsyncResult)
protected override void OnEndOpen(IAsyncResult result)
Parameters
result
IAsyncResult
OnOpen(TimeSpan)
protected override void OnOpen(TimeSpan timeout)
Parameters
timeout
TimeSpan
Receive()
Receives Event Hubs event data.
public EventData Receive()
Returns
Exceptions
- MessagingException
Thrown if the service encounters a transient error.
- MessagingCommunicationException
Thrown if the client has a problem connecting to the service.
- ServerBusyException
Thrown if the current namespace is placing too much load on the system.
- ReceiverDisconnectedException
Thrown if another receiver with a higher Epoch value is connected as the current receiver to the same partition specified by PartitionId.
Receive(int)
Receives Event Hubs event data, up to the specified count.
public IEnumerable<EventData> Receive(int maxCount)
Parameters
maxCount
intThe maximum amount of event data the user is willing to accept in one call.
Returns
- IEnumerable<EventData>
Returns the received EventData collection. The collection is either empty if no event is returned within the specified time, or all events up to
maxCount
are returned.
Exceptions
- MessagingException
Thrown if the service encounters a transient error.
- MessagingCommunicationException
Thrown if the client has a problem connecting to the service.
- ServerBusyException
Thrown if the current namespace is placing too much load on the system.
- ReceiverDisconnectedException
Thrown if another receiver with a higher Epoch value is connected as the current receiver to the same partition specified by PartitionId.
Receive(int, TimeSpan)
Receives Event Hubs event data, up to the specified count with the specified timeout value.
public IEnumerable<EventData> Receive(int maxCount, TimeSpan waitTime)
Parameters
maxCount
intThe maximum amount of event data the user is willing to accept in one call.
waitTime
TimeSpanThe maximum time the user is willing to wait for event data to arrive.
Returns
- IEnumerable<EventData>
Returns the received EventData collection. The collection is either empty if no event is returned within the specified time, or all events up to
maxCount
are returned.
Exceptions
- MessagingException
Thrown if the service encounters a transient error.
- MessagingCommunicationException
Thrown if the client has a problem connecting to the service.
- ServerBusyException
Thrown if the current namespace is placing too much load on the system.
- ReceiverDisconnectedException
Thrown if another receiver with a higher Epoch value is connected as the current receiver to the same partition specified by PartitionId.
Receive(TimeSpan)
Receives Event Hubs event data with the specified timeout value.
public EventData Receive(TimeSpan waitTime)
Parameters
waitTime
TimeSpanThe maximum time the user is willing to wait for event data to arrive.
Returns
Exceptions
- MessagingException
Thrown if the service encounters a transient error.
- MessagingCommunicationException
Thrown if the client has a problem connecting to the service.
- ServerBusyException
Thrown if the current namespace is placing too much load on the system.
- ReceiverDisconnectedException
Thrown if another receiver with a higher Epoch value is connected as the current receiver to the same partition specified by PartitionId.
ReceiveAsync()
Asynchronous version of Receive().
public Task<EventData> ReceiveAsync()
Returns
ReceiveAsync(int)
Asynchronous version of Receive(int).
public Task<IEnumerable<EventData>> ReceiveAsync(int maxCount)
Parameters
maxCount
intThe maximum amount of event data the user is willing to accept in one call.
Returns
- Task<IEnumerable<EventData>>
Returns Task<TResult>.
ReceiveAsync(int, TimeSpan)
Asynchronous version of Receive(int, TimeSpan).
public Task<IEnumerable<EventData>> ReceiveAsync(int maxCount, TimeSpan waitTime)
Parameters
maxCount
intThe maximum amount of event data the user is willing to accept in one call.
waitTime
TimeSpanThe maximum time the user is willing to wait for event data to arrive.
Returns
- Task<IEnumerable<EventData>>
Returns Task<TResult>.
ReceiveAsync(TimeSpan)
Asynchronous version of Receive(TimeSpan).
public Task<EventData> ReceiveAsync(TimeSpan waitTime)
Parameters
waitTime
TimeSpanThe maximum time the user is willing to wait for event data to arrive.