Event Store Kafka

CDI extension for Java EE 8 application using Apache Kafka as Event Store

License

License

Categories

Categories

Net
GroupId

GroupId

net.osomahe
ArtifactId

ArtifactId

eventstore-kafka
Last Version

Last Version

0.4.4
Release Date

Release Date

Type

Type

jar
Description

Description

Event Store Kafka
CDI extension for Java EE 8 application using Apache Kafka as Event Store
Project URL

Project URL

https://github.com/tonda100/eventstore-kafka
Source Code Management

Source Code Management

https://github.com/tonda100/eventstore-kafka

Download eventstore-kafka

How to add to project

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

Dependencies

compile (1)

Group / Artifact Type Version
org.apache.kafka : kafka-clients jar 2.4.0

provided (1)

Group / Artifact Type Version
javax : javaee-api jar 8.0

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

Event Store Kafka

CDI extension for Java EE 8 application using Apache Kafka as Event Store.

Build Status License

Five minute start

How to quickly start using the Event Store Kafka with your Java EE 8 project.

Setup

  1. Add maven dependencies to your pom.xml
    <dependency>
        <groupId>net.osomahe</groupId>
        <artifactId>eventstore-kafka</artifactId>
        <version>0.4.3</version>
    </dependency>
  2. Added extensions src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
    net.osomahe.esk.EventStoreExtension
    

Producing events

  1. Extend AbstractEvent class
  2. Use EventStorePublisher#publish(event) method for publishing event to Apache Kafka synchronously. or
  3. Use EventStorePublisher#publishAsync(event) method for publishing event to Apache Kafka asynchronously.

Consuming events

  1. Extend AbstractEvent class or use the same as for publishing.
  2. Observes for CDI event
    public void handleCreate(@Observes TodoCreatedEvent event) {
        // do some magic with event
    }

Advanced

Configuration possibilities and default values. Unfortunately JavaEE 8 does not have any standard means of configuration and I didn't want to

Configuration

Unfortunately JavaEE 8 does not provide any standard way. There are two ways of configuring the eventstore-kafka.

  1. Application has to produce using @Produces and correct qualifier see example:
  • java.util.Properties with qualifiers @KafkaProducerConfig for overriding producer properties otherwise default values will be in place.
    Properties props = new Properties();
    props.put(BOOTSTRAP_SERVERS_CONFIG, "localhost:9092");
    props.put(ACKS_CONFIG, "all");
  • java.util.Properties with qualifiers @KafkaConsumerConfig for overriding consumer properties otherwise default values will be in place.
    Properties props = new Properties();
    props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092");
    props.put(GROUP_ID_CONFIG, "client-application");
    props.put(AUTO_OFFSET_RESET_CONFIG, "earliest");
  1. Application has to implement EventStorePublisherConfig and (or) EventStoreConsumerConfig to provide non-default properties

Customization

  • @TopicName annotation for an event class to set different topic for given event(s)
  • @EventName annotation for an event class to set different event name
  • @AsyncEvent annotation for an event class to set asynchronous processing of events @ObeservesAsync required for handling async events

Versions

Version
0.4.4
0.4.3
0.4.2
0.4.1
0.4.0
0.3.0
0.2.0
0.1.0