Apache Avro Client Library Configuration Options
You can set the following Apache Avro client library configuration options programmatically with Java properties for either an Apache Kafka Producer or Consumer.
Configuration Properties
Property Name | Type | Description |
---|---|---|
key.subject.name | String | Subject in the schema repository that the client library registers new key schemas under. |
value.subject.name | String | Subject in the schema repository that the client library registers new value schemas under. |
ftl.realmservers | String | Pipe-delimited list of FTL Server URLs.
Default: localhost:8081. |
schema.registry.url | String | Comma-delimited list of Schema Registry URLs; this overrides the list in
ftl.realmservers if set.
Note: Using ftl.realmservers is recommended, rather than this property. This property is intended primarily for compatibility with existing configuration files that use this style of delimiting. |
ftl.trust.type | String | FTL trust type ("file", "everyone", or "string", as per usual in other products). |
ftl.trust.file | String | FTL trust file path. |
ftl.trust.string | String | FTL trust certificate PEM string. |
ftl.username | String | FTL Server username. |
ftl.password | String | FTL Server password. |
schema.registration.strategy | String | Valid values are:
auto - (default) If the latest version of the schema registered under the producer topic's subject does not match the schema of the message the producer is sending, or, if no schema is registered yet, then register a schema matching the producer's message before sending it. none - Do not register a schema. If a matching schema does not already exist for the producer's topic, then the producer fails to send. latest - Do not register a schema. Instead, use the latest version of the producer topic's schema, even if it is not an exact match. If a schema does not exist for the producer's topic, then the producer fails to send. |
Use Examples
Following are excerpts from the included AvroConsumer sample application.
Properties properties = new Properties(); . . . // Required list of Kafka brokers. properties.setProperty("bootstrap.servers", "localhost:9092"); // We expect to receive messages in TIBCO's Avro format, so we will use TIBCO's AvroDeserializer // class from 'tibftl-kafka-avro-1.3.0.jar' to deserialize both the keys and the values of // incoming messages. properties.setProperty("key.deserializer", "com.tibco.messaging.kafka.avro.AvroDeserializer"); properties.setProperty("value.deserializer", "com.tibco.messaging.kafka.avro.AvroDeserializer"); // List of TIBCO FTL server URLs. The FTL server forwards schema repository requests // to the schema repository server and handles automatic failover of schema repository servers. // In this example, we assume that the FTL server is running locally and listening on // port 13131, and that the schema repository is also running and configured with the same FTL // servers list. properties.setProperty("ftl.realmservers", "http://localhost:13131/"); . . . KafkaConsumer<Object, GenericRecord> consumer = new KafkaConsumer<>(properties);
For a producer application, the same options can be applied, except use key.serializer and value.serializer in place of key.deserializer and value.deserializer.
// We want to send messages in TIBCO's Avro format, so we will use TIBCO's AvroSerializer // class from 'tibftl-kafka-avro-1.3.0.jar' to serialize both the keys and the values of // outgoing messages. properties.setProperty("key.serializer", "com.tibco.messaging.kafka.avro.AvroSerializer"); properties.setProperty("value.serializer", "com.tibco.messaging.kafka.avro.AvroSerializer"); . . . KafkaProducer<Object, GenericRecord> producer = new KafkaProducer<>(properties);