Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).

Motivation

Users currently need to type in a HashMap for connection properties on Producers, Consumers and AdminClient.

The API could be simplified here by allowing a single line with string properties, what would be:

  • simpler to use, easier for newer users
  • Single string object for configuration
    • This would allow users to store their configurations in single places, in a better fashion. Example property files with a single object string

Example of current code:

Map<String, Object> config = new HashMap<>();
config.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9999");
config.put(ConsumerConfig.RECEIVE_BUFFER_CONFIG, -2);
KafkaConsumer consumer = new KafkaConsumer<>(config, new ByteArrayDeserializer(), new ByteArrayDeserializer());
 

This following code would be the equivalent piece for the previous example.

KafkaConsumer consumer = new KafkaConsumer("localhost:9999;receiver.buffer.bytes=-2", new ByteArrayDeserializer(), new ByteArrayDeserializer());The idea is that you should be able to connect to the server using a connection string instead:


KafkaConsumer consumer = new KafkaConsumer("localhost:9999,localhost2:99999;parameter1=value2;parameter2=value3", new new ByteArrayDeserializer(), new new ByteArrayDeserializer());

This is similar to what users are used when connecting to Databases (e.g. JDBC), other message systems or many other server solutions.

Public Interfaces

No public interfaces would be added, however a new contructor would be added to KafkaConsumer, KafkaProducer and KafkaAdminClient

...

My proposed format for the connection string would be:

IP1host1:host1port1,IP2host2:host2,...IPN:hostn;parameterName=value1;parameterName2=value2;... parameterNameN=valueNport2,…host:portn;param-name1=param-val1,..param-nameN=param-valN

 

Invalid conversions would throw InvalidArgumentException (with a description of the invalid conversion)

...