Indicates whether the consumer is currently receiving messages or not.
When this returns true, new receive()
or receiveBatch()
calls cannot be made.
Closes the underlying AMQP receiver link.
Once closed, the consumer cannot be used for any further operations.
Use the createConsumer
function on the EventHubClient to instantiate
a new EventHubConsumer.
Returns an async iterable that retrieves events.
The async iterable cannot indicate that it is done.
When using for await (let event of consumer.getEventIterator()) {}
to iterate over the events returned
by the async iterable, take care to exit the for loop after receiving the
desired number of messages, or provide an AbortSignal
to control when to exit the loop.
Starts receiving events from the service and calls the user provided message handler for each event. Returns an object that can be used to query the state of the receiver and to stop receiving events as well.
The message handler to receive event data objects.
The error handler for errora that can occur when receiving events.
An implementation of the AbortSignalLike
interface to signal the request to cancel the operation.
For example, use the @azure/abort-controller to create an AbortSignal
.
ReceiveHandler - An object that provides a mechanism to stop receiving more messages.
Returns a promise that resolves to an array of events received from the service.
The maximum number of messages to receive.
The maximum amount of time to wait to build up the requested message count; If not provided, it defaults to 60 seconds.
An implementation of the AbortSignalLike
interface to signal the request to cancel the operation.
For example, use the @azure/abort-controller to create an AbortSignal
.
Promise<ReceivedEventData[]>.
Generated using TypeDoc
A consumer is responsible for reading
EventData
from a specific Event Hub partition in the context of a specific consumer group. To create a consumer use thecreateConsumer()
method on yourEventHubClient
.You can pass the below in the
options
when creating a consumer.ownerLevel
: A number indicating that the consumer intends to be an exclusive consumer of events resulting in other consumers to fail if theirownerLevel
is lower or doesn't exist.retryOptions
: The retry options used to govern retry attempts when an issue is encountered while receiving events.Multiple consumers are allowed on the same partition in a consumer group. If there is a need to have an exclusive consumer for a partition in a consumer group, then specify the
ownerLevel
in theoptions
. Exclusive consumers were previously referred to as "Epoch Receivers".The consumer can be used to receive messages in a batch using
receiveBatch()
or by registering handlers by usingreceive()
or via an async iterable got by usinggetEventIterator()