Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thody/heroku-kafka-connection-helper
A Java library to help configure Kafka client connection Properties from Heroku Kafka environment variables.
https://github.com/thody/heroku-kafka-connection-helper
heroku kafka
Last synced: 18 days ago
JSON representation
A Java library to help configure Kafka client connection Properties from Heroku Kafka environment variables.
- Host: GitHub
- URL: https://github.com/thody/heroku-kafka-connection-helper
- Owner: thody
- License: mit
- Created: 2017-05-05T17:20:27.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-05-09T13:22:01.000Z (over 7 years ago)
- Last Synced: 2023-06-29T17:44:43.881Z (over 1 year ago)
- Topics: heroku, kafka
- Language: Java
- Size: 43 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Heroku Kafka Connection Helper [![Build Status](https://travis-ci.org/thody/heroku-kafka-connection-helper.svg?branch=master)](https://travis-ci.org/thody/heroku-kafka-connection-helper) [![Maven Central](https://img.shields.io/maven-central/v/com.adamthody/heroku-kafka-connection-helper.svg)](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.adamthody%22%20AND%20a%3A%22heroku-kafka-connection-helper%22)
A Java library to help configure Kafka client connection Properties from Heroku Kafka environment variables.
## Usage
Include this library in your application as a Maven dependency:
```xml
com.adamthody
heroku-kafka-connection-helper
0.1.9```
### Configuring a Client
Calling `HerokuKafkaConnectionHelper.getConfigProperties()` will return a Properties object that has the appropriate connection
properties set, as per the environment variables available.Based on the URL scheme of the `KAFKA_URL` environment variable, the properties will either be for a simple plaintext
connection, or it will configure an SSL connection, including the KeyStore and TrustStore.
Heroku Kafka uses SSL by default, but by setting `KAFKA_URL` locally, you can also test against a local cluster with a
plaintext connection for local development without having to modify code.```java
Properties properties = HerokuKafkaConnectionHelper.getConfigProperties();
... // Additional properties
KafkaConsumer consumer = new KafkaConsumer<>(properties);
```If you're using Spring's `ProducerFactory` or `ConsumerFactory`, you may prefer to get your connection configuration as
a Map.
```java
Map configMap = HerokuKafkaConnectionHelper.getConfigMap();
... // Additional properties
ProducerFactory producer = new DefaultKafkaProducerFactory<>(configMap);
```