use of org.eclipse.hono.application.client.kafka.impl.KafkaApplicationClientImpl in project hono by eclipse.
the class HonoExampleApplicationBase method createKafkaApplicationClient.
/**
* Creates an application client for Kafka based messaging. Unlike with AMQP, the Kafka clients manage their
* connections to the cluster internally.
* <p>
* NB: if you want to integrate this code with your own software, it might be necessary to copy the trust store to
* your project as well and adopt the file path.
*/
private ApplicationClient<? extends MessageContext> createKafkaApplicationClient() {
final Map<String, String> properties = new HashMap<>();
properties.put("bootstrap.servers", HonoExampleConstants.HONO_MESSAGING_HOST + ":" + port);
// add the following lines with appropriate values to enable TLS
// properties.put("ssl.truststore.location", "/path/to/file");
// properties.put("ssl.truststore.password", "secret");
final CommonKafkaClientConfigProperties commonClientConfig = new CommonKafkaClientConfigProperties();
commonClientConfig.setCommonClientConfig(properties);
final MessagingKafkaConsumerConfigProperties consumerConfig = new MessagingKafkaConsumerConfigProperties();
consumerConfig.setCommonClientConfig(commonClientConfig);
consumerConfig.setConsumerConfig(Map.of("group.id", KAFKA_CONSUMER_GROUP_ID));
final MessagingKafkaProducerConfigProperties producerConfig = new MessagingKafkaProducerConfigProperties();
producerConfig.setCommonClientConfig(commonClientConfig);
final KafkaProducerFactory<String, Buffer> producerFactory = CachingKafkaProducerFactory.sharedFactory(vertx);
return new KafkaApplicationClientImpl(vertx, consumerConfig, producerFactory, producerConfig);
}
use of org.eclipse.hono.application.client.kafka.impl.KafkaApplicationClientImpl in project hono by eclipse.
the class IntegrationTestSupport method init.
/**
* Connects to Kafka.
* <p>
* Also creates an HTTP client for accessing the Device Registry.
*
* @param kafkaDownstreamProps The properties for connecting to Kafka.
*
* @return A future indicating the outcome of the operation.
*/
public Future<Void> init(final MessagingKafkaConsumerConfigProperties kafkaDownstreamProps) {
initRegistryClient();
kafkaProducerFactory = CachingKafkaProducerFactory.sharedFactory(vertx);
applicationClient = new KafkaApplicationClientImpl(vertx, kafkaDownstreamProps, kafkaProducerFactory, getKafkaProducerConfig());
return Future.succeededFuture();
}
Aggregations