Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 49 additions & 50 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,91 +1,93 @@
<h1 align="center">
Java Kafka Publisher (JaKaPu)
</h1>
<h1 align="center">
<img src='images/jakapu.png' alt="Jakapu - Amex" width='50%'/>
Java Kafka Publisher (JaKaPu)
</h1>
<p align="center">
<img src="images/jakapu.png" alt="Jakapu - Amex" width="50%" />
</p>

**Jakapu is a config driven SDK to publish events into any Kafka topic without writing code**
<p align="center"><b>
JaKaPu is a config-driven SDK to publish events to Kafka topics without writing any boilerplate code.
</b></p>

---

## ✨ Features

- Build a Kafka Publisher with a single @annotation
- Convert your existing Springboot app to a Kafka publisher
- Publish message into multiple kafka topics
- Route messages into multiple kafka topics based on a header key
- Validate the kafka header and their values before publishing message into kafka
- Configuration driven Kafka broker, topic configuration
- Publish to kafka with ssl enabled or disabled
- Also provides a REST API end point @/jakapu/publish to publish messages into kakfa
- Build a Kafka Publisher using a single @annotation
- Seamlessly integrate into existing Spring Boot applications
- Publish messages to multiple Kafka topics
- Route messages based on header keys
- Validate Kafka headers before publishing
- Easily configure broker, topic, and security settings via YAML
- Built-in REST endpoint `/jakapu/publish` for publishing messages

---

## 📖 Prerequisites

- Maven 3+
- Java 8+
- Spring framework
- Kafka Topic
- Maven 3+
- Spring Framework
- Kafka Topic(s)


## 🤹‍ Getting Started
---

## 🚀 Getting Started

##### Add maven dependency
### Add Maven Dependency

```java
```xml
<dependency>
<groupId>com.americanexpress.jakapu</groupId>
<artifactId>jakapu</artifactId>
<version>${latest.version}</version>
<groupId>com.americanexpress.jakapu</groupId>
<artifactId>jakapu</artifactId>
<version>${latest.version}</version>
</dependency>
```


##### Add @EnableJakapu as a dependency annotation on Spring Boot Main Application class.

```java
@EnableJakapu
public class SampleSpringApplication {
@EnableJakapu
public class SampleSpringApplication {

public static void main(String[] args) {
logger.info("Spring Boot Sample App Started.............");
ApplicationContext app = SpringApplication.run(SampleSpringApplication.class);
}
public static void main(String[] args) {
logger.info("Spring Boot Sample App Started.............");
ApplicationContext app = SpringApplication.run(SampleSpringApplication.class);
}
}
```


##### Configure :
- dynamically add any number of topics to your configuration under **jakapu.psf.publisher.topics**
- define mandatory kafka header attribute names and their validation pattern(**jakapu.psf.publisher.payload.headerAtribute**)
- header-based topic routing can be added in the configuration under **Jakapu.psf.publisher.headerTopicMap**

- Dynamically add any number of topics to your configuration under **jakapu.psf.publisher.topics**
- Define mandatory kafka header attribute names and their validation pattern(**jakapu.psf.publisher.payload.headerAttribute**)
- Header-based topic routing can be added in the configuration under **Jakapu.psf.publisher.headerTopicMap**

```yaml
jakapu:
psf:
publisher:
topics:
- name: Topic1
id: t1
numPartitions: 4
replication-factor: 1
- name: Topic2
id: t2
numPartitions: 8
replication-factor: 1
- name: Topic1
id: t1
numPartitions: 4
replication-factor: 1
- name: Topic2
id: t2
numPartitions: 8
replication-factor: 1

payload:
headerAttribute:
source-type: "re(jakapu.psf.payload.headerTopicMap)"
event-type: "rx(\\w{1,})" #Java Regex to validate the type of event. Accepts any string size more than 1.
source-uniqueid: "rx(\\w{1,})" #Java Regex to validate string. Accepts any string size more than 1.
source-uniqueid: "rx(\\w{1,})" #Java Regex to validate string. Accepts any string size more than 1.
source-timestamp: "rx(\\d{13})" #Java Regex to validate timestamp. 13 digit number.
headerTopicMap:
MySource1: t1
MySource2: t2

### kafka config related to broker, ssl, keystores etc
### kafka config related to broker, ssl, keystores etc

kafka:
security:
Expand All @@ -105,7 +107,6 @@ jakapu:
bootstrap-servers: "yourkafka.domain.com"
```


##### To publish a message, autowire Publisher interface and then use the API call - **publisher.publish()**

```java
Expand Down Expand Up @@ -137,19 +138,17 @@ https://hostname/jakapu/publish

We welcome Your interest in the American Express Open Source Community on Github. Any Contributor to
any Open Source Project managed by the American Express Open Source Community must accept and sign
an Agreement indicating agreement to the terms below. Except for the rights granted in this
an Agreement indicating agreement to the terms below. Except for the rights granted in this
Agreement to American Express and to recipients of software distributed by American Express, You
reserve all right, title, and interest, if any, in and to Your Contributions. Please
[fill out the Agreement](https://cla-assistant.io/americanexpress/jakapu).


## 🗝️ License

Any contributions made under this project will be governed by the
[Apache License 2.0](./LICENSE.txt).


## 🗣️ Code of Conduct

This project adheres to the [American Express Community Guidelines](./CODE_OF_CONDUCT.md).
This project adheres to the [American Express Community Guidelines](./CODE_OF_CONDUCT.md).
By participating, you are expected to honor these guidelines.