Interface IClient
Defines methods common to all client types.
Inherited Members
Namespace: Confluent.Kafka
Assembly: Confluent.Kafka.dll
Syntax
public interface IClient : IDisposable
Properties
Handle
An opaque reference to the underlying librdkafka client instance. This can be used to construct an AdminClient that utilizes the same underlying librdkafka client as this instance.
Declaration
Handle Handle { get; }
Property Value
Type | Description |
---|---|
Handle |
Name
Gets the name of this client instance.
Contains (but is not equal to) the client.id configuration parameter.
Declaration
string Name { get; }
Property Value
Type | Description |
---|---|
string |
Remarks
This name will be unique across all client instances in a given application which allows log messages to be associated with the corresponding instance.
Methods
AddBrokers(string)
Adds one or more brokers to the Client's list of initial bootstrap brokers.
Note: Additional brokers are discovered automatically as soon as the Client connects to any broker by querying the broker metadata. Calling this method is only required in some scenarios where the address of all brokers in the cluster changes.
Declaration
int AddBrokers(string brokers)
Parameters
Type | Name | Description |
---|---|---|
string | brokers | Comma-separated list of brokers in the same format as the bootstrap.server configuration parameter. |
Returns
Type | Description |
---|---|
int | The number of brokers added. This value includes brokers that may have been specified a second time. |
Remarks
There is currently no API to remove existing configured, added or learnt brokers.
SetSaslCredentials(string, string)
SetSaslCredentials sets the SASL credentials used for this client. The new credentials will overwrite the old ones (which were set when creating client or by a previous call to SetSaslCredentials). The new credentials will be used the next time the client needs to authenticate to a broker. This method will not disconnect existing broker connections that were established with the old credentials. This method applies only to the SASL PLAIN and SCRAM mechanisms.
Declaration
void SetSaslCredentials(string username, string password)
Parameters
Type | Name | Description |
---|---|---|
string | username | The username to set. |
string | password | The password to set. |