Heroku Kafka Connection Helper

A Java library to help configure Kafka client connection Properties from Heroku Kafka environment variables.

License

License

MIT
Categories

Categories

Heroku Container PaaS Providers
GroupId

GroupId

com.adamthody
ArtifactId

ArtifactId

heroku-kafka-connection-helper
Last Version

Last Version

0.1.9
Release Date

Release Date

Type

Type

jar
Description

Description

Heroku Kafka Connection Helper
A Java library to help configure Kafka client connection Properties from Heroku Kafka environment variables.
Project URL

Project URL

https://github.com/thody/heroku-kafka-connection-helper
Source Code Management

Source Code Management

https://github.com/thody/heroku-kafka-connection-helper

Download heroku-kafka-connection-helper

How to add to project

<!-- https://jarcasting.com/artifacts/com.adamthody/heroku-kafka-connection-helper/ -->
<dependency>
    <groupId>com.adamthody</groupId>
    <artifactId>heroku-kafka-connection-helper</artifactId>
    <version>0.1.9</version>
</dependency>
// https://jarcasting.com/artifacts/com.adamthody/heroku-kafka-connection-helper/
implementation 'com.adamthody:heroku-kafka-connection-helper:0.1.9'
// https://jarcasting.com/artifacts/com.adamthody/heroku-kafka-connection-helper/
implementation ("com.adamthody:heroku-kafka-connection-helper:0.1.9")
'com.adamthody:heroku-kafka-connection-helper:jar:0.1.9'
<dependency org="com.adamthody" name="heroku-kafka-connection-helper" rev="0.1.9">
  <artifact name="heroku-kafka-connection-helper" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.adamthody', module='heroku-kafka-connection-helper', version='0.1.9')
)
libraryDependencies += "com.adamthody" % "heroku-kafka-connection-helper" % "0.1.9"
[com.adamthody/heroku-kafka-connection-helper "0.1.9"]

Dependencies

compile (1)

Group / Artifact Type Version
com.github.jkutner : env-keystore jar 0.1.2

test (2)

Group / Artifact Type Version
junit : junit jar 4.12
com.github.stefanbirkner : system-rules jar 1.16.0

Project Modules

There are no modules declared in this project.

Heroku Kafka Connection Helper Build Status Maven Central

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:

<dependency>
  <groupId>com.adamthody</groupId>
  <artifactId>heroku-kafka-connection-helper</artifactId>
  <version>0.1.9</version>
</dependency>

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.

Properties properties = HerokuKafkaConnectionHelper.getConfigProperties();
... // Additional properties
KafkaConsumer<Integer, String> consumer = new KafkaConsumer<>(properties);

If you're using Spring's ProducerFactory or ConsumerFactory, you may prefer to get your connection configuration as a Map.

Map<String, Object> configMap = HerokuKafkaConnectionHelper.getConfigMap();
... // Additional properties
ProducerFactory<Integer, String> producer = new DefaultKafkaProducerFactory<>(configMap);

Versions

Version
0.1.9
0.1.8
0.1.7