public class EventHubAsyncClient extends Object implements Closeable
Instantiated through EventHubClientBuilder.
Creating an EventHubAsyncClient using an Event Hubs namespace connection string
StringconnectionString = "Endpoint={endpoint};SharedAccessKeyName={sharedAccessKeyName};" + "SharedAccessKey={sharedAccessKey}";StringeventHubName = "my-event-hub";EventHubAsyncClientclient = newEventHubClientBuilder() .connectionString(connectionString, eventHubName) .buildAsyncClient();
Creating an EventHubAsyncClient using an Event Hub instance connection string
StringconnectionString = "Endpoint={endpoint};SharedAccessKeyName={sharedAccessKeyName};" + "SharedAccessKey={sharedAccessKey};EntityPath={eventHubName}";EventHubAsyncClientclient = newEventHubClientBuilder() .connectionString(connectionString) .buildAsyncClient();
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes and disposes of connection to service.
|
EventHubConsumerAsyncClient |
createConsumer(String consumerGroup,
EventPosition eventPosition)
Creates an Event Hub consumer responsible for reading
EventData from a specific Event Hub partition, as a
member of the specified consumer group, and begins reading events from the eventPosition. |
EventHubConsumerAsyncClient |
createConsumer(String consumerGroup,
EventPosition eventPosition,
EventHubConsumerOptions options)
Creates an Event Hub consumer responsible for reading
EventData from a specific Event Hub partition, as a
member of the configured consumer group, and begins reading events from the specified eventPosition. |
EventHubProducerAsyncClient |
createProducer()
Creates an Event Hub producer responsible for transmitting
EventData to the Event Hub, grouped together
in batches. |
String |
getEventHubName()
Gets the Event Hub name this client interacts with.
|
Flux<String> |
getPartitionIds()
Retrieves the identifiers for the partitions of an Event Hub.
|
Mono<PartitionProperties> |
getPartitionProperties(String partitionId)
Retrieves information about a specific partition for an Event Hub, including elements that describe the available
events in the partition event stream.
|
Mono<EventHubProperties> |
getProperties()
Retrieves information about an Event Hub, including the number of partitions present and their identifiers.
|
public String getEventHubName()
public Mono<EventHubProperties> getProperties()
public Flux<String> getPartitionIds()
public Mono<PartitionProperties> getPartitionProperties(String partitionId)
partitionId - The unique identifier of a partition associated with the Event Hub.public EventHubProducerAsyncClient createProducer()
EventData to the Event Hub, grouped together
in batches.EventHubProducerAsyncClient.public EventHubConsumerAsyncClient createConsumer(String consumerGroup, EventPosition eventPosition)
EventData from a specific Event Hub partition, as a
member of the specified consumer group, and begins reading events from the eventPosition.
The consumer created is non-exclusive, allowing multiple consumers from the same consumer group to be actively
reading events from the partition. These non-exclusive consumers are sometimes referred to as "Non-epoch
Consumers".consumerGroup - The name of the consumer group this consumer is associated with. Events are read in the
context of this group. The name of the consumer group that is created by default is "$Default".eventPosition - The position within the partition where the consumer should begin reading events.EventHubConsumerAsyncClient that receives events from the partition at the given position.NullPointerException - If eventPosition, or options is null.IllegalArgumentException - If consumerGroup or partitionId is null or an empty
string.public EventHubConsumerAsyncClient createConsumer(String consumerGroup, EventPosition eventPosition, EventHubConsumerOptions options)
EventData from a specific Event Hub partition, as a
member of the configured consumer group, and begins reading events from the specified eventPosition.
A consumer may be exclusive, which asserts ownership over the partition for the consumer group to ensure that
only one consumer from that group is reading the from the partition. These exclusive consumers are sometimes
referred to as "Epoch Consumers."
A consumer may also be non-exclusive, allowing multiple consumers from the same consumer group to be actively
reading events from the partition. These non-exclusive consumers are sometimes referred to as "Non-epoch
Consumers."
Designating a consumer as exclusive may be specified in the options, by setting EventHubConsumerOptions.setOwnerLevel(Long) to a non-null value. By default, consumers are created as
non-exclusive.
consumerGroup - The name of the consumer group this consumer is associated with. Events are read in the
context of this group. The name of the consumer group that is created by default is
"$Default".eventPosition - The position within the partition where the consumer should begin reading events.options - The set of options to apply when creating the consumer.EventHubConsumerAsyncClient that receives events from the partition with all configured
EventHubConsumerOptions.NullPointerException - If eventPosition, consumerGroup, partitionId, or
options is null.IllegalArgumentException - If consumerGroup or partitionId is an empty string.public void close()
EventHubConsumers and
EventHubProducers created with this instance will have their connections
closed.close in interface Closeableclose in interface AutoCloseableCopyright © 2019 Microsoft Corporation. All rights reserved.