EventHubClient Class
The EventHubClient class defines a high level interface for sending events to and receiving events from the Azure Event Hubs service.
- Inheritance
-
builtins.objectEventHubClient
Constructor
EventHubClient(address, username=None, password=None, debug=False, http_proxy=None, auth_timeout=60, sas_token=None)
Parameters
- address
- username
- password
- debug
- http_proxy
- auth_timeout
- sas_token
Methods
| add_epoch_receiver |
Add a receiver to the client with an epoch value. Only a single epoch receiver can connect to a partition at any given time - additional epoch receivers must have a higher epoch value or they will be rejected. If a 2nd epoch receiver has connected, the first will be closed. |
| add_receiver |
Add a receiver to the client for a particular consumer group and partition. |
| add_sender |
Add a sender to the client to EventData object to an EventHub. |
| create_properties |
Format the properties with which to instantiate the connection. This acts like a user agent over HTTP. |
| from_connection_string |
Create an EventHubClient from a connection string. |
| from_iothub_connection_string |
Create an EventHubClient from an IoTHub connection string. |
| from_sas_token |
Create an EventHubClient from an existing auth token or token generator. |
| get_eventhub_info |
Get details on the specified EventHub. Keys in the details dictionary include: -'name' -'type' -'created_at' -'partition_count' -'partition_ids' |
| run |
Run the EventHubClient in blocking mode. Opens the connection and starts running all Sender/Receiver clients. Returns a list of the start up results. For a succcesful client start the result will be None, otherwise the exception raised. If all clients failed to start, then run will fail, shut down the connection and raise an exception. If at least one client starts up successfully the run command will succeed. |
| stop |
Stop the EventHubClient and all its Sender/Receiver clients. |
add_epoch_receiver
Add a receiver to the client with an epoch value. Only a single epoch receiver can connect to a partition at any given time - additional epoch receivers must have a higher epoch value or they will be rejected. If a 2nd epoch receiver has connected, the first will be closed.
add_epoch_receiver(consumer_group, partition, epoch, prefetch=300, operation=None, keep_alive=30, auto_reconnect=True)
Parameters
- operation
- keep_alive
- auto_reconnect
Return type
add_receiver
Add a receiver to the client for a particular consumer group and partition.
add_receiver(consumer_group, partition, offset=None, prefetch=300, operation=None, keep_alive=30, auto_reconnect=True)
Parameters
- operation
- keep_alive
- auto_reconnect
Return type
add_sender
Add a sender to the client to EventData object to an EventHub.
add_sender(partition=None, operation=None, send_timeout=60, keep_alive=30, auto_reconnect=True)
Parameters
- partition
Optionally specify a particular partition to send to. If omitted, the events will be distributed to available partitions via round-robin.
- send_timeout
- int
The timeout in seconds for an individual event to be sent from the time that it is queued. Default value is 60 seconds. If set to 0, there will be no timeout.
- keep_alive
- int
The time interval in seconds between pinging the connection to keep it alive during periods of inactivity. The default value is 30 seconds. If set to None, the connection will not be pinged.
- auto_reconnect
Whether to automatically reconnect the sender if a retryable error occurs. Default value is True.
- auto_reconnect
Return type
create_properties
Format the properties with which to instantiate the connection. This acts like a user agent over HTTP.
create_properties()
Return type
from_connection_string
Create an EventHubClient from a connection string.
from_connection_string(conn_str, eventhub=None, **kwargs)
Parameters
- eventhub
- str
The name of the EventHub, if the EntityName is not included in the connection string.
- debug
- bool
Whether to output network trace logs to the logger. Default is False.
HTTP proxy settings. This must be a dictionary with the following keys: 'proxy_hostname' (str value) and 'proxy_port' (int value). Additionally the following keys may also be present: 'username', 'password'.
- auth_timeout
- int
The time in seconds to wait for a token to be authorized by the service. The default value is 60 seconds. If set to 0, no timeout will be enforced from the client.
from_iothub_connection_string
Create an EventHubClient from an IoTHub connection string.
from_iothub_connection_string(conn_str, **kwargs)
Parameters
HTTP proxy settings. This must be a dictionary with the following keys: 'proxy_hostname' (str value) and 'proxy_port' (int value). Additionally the following keys may also be present: 'username', 'password'.
- auth_timeout
- int
The time in seconds to wait for a token to be authorized by the service. The default value is 60 seconds. If set to 0, no timeout will be enforced from the client.
from_sas_token
Create an EventHubClient from an existing auth token or token generator.
from_sas_token(address, sas_token, eventhub=None, **kwargs)
Parameters
A SAS token or function that returns a SAS token. If a function is supplied, it will be used to retrieve subsequent tokens in the case of token expiry. The function should take no arguments.
- debug
- bool
Whether to output network trace logs to the logger. Default is False.
HTTP proxy settings. This must be a dictionary with the following keys: 'proxy_hostname' (str value) and 'proxy_port' (int value). Additionally the following keys may also be present: 'username', 'password'.
- auth_timeout
- int
The time in seconds to wait for a token to be authorized by the service. The default value is 60 seconds. If set to 0, no timeout will be enforced from the client.
get_eventhub_info
Get details on the specified EventHub. Keys in the details dictionary include:
-'name' -'type' -'created_at' -'partition_count' -'partition_ids'
get_eventhub_info()
Return type
run
Run the EventHubClient in blocking mode. Opens the connection and starts running all Sender/Receiver clients. Returns a list of the start up results. For a succcesful client start the result will be None, otherwise the exception raised. If all clients failed to start, then run will fail, shut down the connection and raise an exception. If at least one client starts up successfully the run command will succeed.
run()
Return type
stop
Stop the EventHubClient and all its Sender/Receiver clients.
stop()
Feedback
Submit and view feedback for