Skip to content

Commit

Permalink
split kafka-avro to producer and consumer (#315)
Browse files Browse the repository at this point in the history
* Initial commit of spliting

* fixes build issue

* creates pipelines

* removes producer side code

* configure properties at correct place

* Running in saperate port to run parallely

---------

Co-authored-by: Raja Dilip Kolli <[email protected]>
  • Loading branch information
rajadilipkolli and rajadileepkolli committed May 12, 2023
1 parent c7d5004 commit b0c0a6a
Show file tree
Hide file tree
Showing 27 changed files with 1,585 additions and 26 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/spring-boot-kafka-avro-consumer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: spring-boot-kafka-avro-consumer

on:
push:
paths:
- "kafka-avro/spring-boot-kafka-avro-consumer/**"
branches: [ master ]
pull_request:
paths:
- "kafka-avro/spring-boot-kafka-avro-consumer/**"
types:
- opened
- synchronize
- reopened

jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: "kafka-avro/spring-boot-kafka-avro-consumer"
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up JDK
uses: actions/[email protected]
with:
java-version: '17'
distribution: 'microsoft'
cache: 'maven'
- name: Build with Maven
run: ./mvnw -B clean verify --file pom.xml
16 changes: 13 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,21 @@
},
{
"type": "java",
"name": "Spring Boot-SpringBootKafkaAvroApplication<spring-boot-kafka-avro>",
"name": "Spring Boot-SpringBootKafkaAvroConsumerApplication<spring-boot-kafka-avro-consumer>",
"request": "launch",
"cwd": "${workspaceFolder}",
"mainClass": "com.example.springbootkafkaavro.SpringBootKafkaAvroApplication",
"projectName": "spring-boot-kafka-avro",
"mainClass": "com.example.springbootkafkaavro.SpringBootKafkaAvroConsumerApplication",
"projectName": "spring-boot-kafka-avro-consumer",
"args": "",
"envFile": "${workspaceFolder}/.env"
},
{
"type": "java",
"name": "Spring Boot-SpringBootKafkaAvroProducerApplication<spring-boot-kafka-avro-producer>",
"request": "launch",
"cwd": "${workspaceFolder}",
"mainClass": "com.example.springbootkafkaavro.SpringBootKafkaAvroProducerApplication",
"projectName": "spring-boot-kafka-avro-producer",
"args": "",
"envFile": "${workspaceFolder}/.env"
}
Expand Down
31 changes: 31 additions & 0 deletions kafka-avro/spring-boot-kafka-avro-consumer/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**
!**/src/test/**

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/

### VS Code ###
.vscode/
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.2/apache-maven-3.9.2-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
17 changes: 17 additions & 0 deletions kafka-avro/spring-boot-kafka-avro-consumer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# kafka avro


Apache Kafka is an open-source stream-processing platform that is used for building real-time data pipelines and streaming apps. It is horizontally scalable, fault-tolerant, and fast.

Apache Avro is a data serialization system that that provides a compact and efficient binary format for data serialization and is commonly used with Apache Kafka. It is a compact and efficient binary format that allows for the serialization of data with a schema. This means that the structure of the data can be defined, and the data can be self-describing, which can be useful when working with complex data structures.

Together, Kafka and Avro can be used to create a powerful platform for building real-time data pipelines and streaming applications. Avro is often used with Kafka because it supports schema evolution, which allows for the evolution of data over time without the need to update all the systems that are consuming that data. This makes it an ideal choice for use with Kafka, where data is constantly being generated and consumed by a variety of systems.


### Run locally
`$ ./mvnw spring-boot:run`

### Useful Links
* Swagger UI: http://localhost:8080/swagger-ui.html
* Actuator Endpoint: http://localhost:8080/actuator
* Schema Registry : http://localhost:8081/subjects/persons-value/versions?normalize=false
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
version: '3.9'

services:
kafka:
image: confluentinc/cp-kafka:7.4.0
hostname: broker
container_name: broker
ports:
- "9092:9092"
- "9101:9101"
environment:
KAFKA_BROKER_ID: 1
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: 'CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT'
KAFKA_ADVERTISED_LISTENERS: 'PLAINTEXT://broker:29092,PLAINTEXT_HOST://localhost:9092'
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
KAFKA_JMX_PORT: 9101
KAFKA_JMX_HOSTNAME: localhost
KAFKA_PROCESS_ROLES: 'broker,controller'
KAFKA_NODE_ID: 1
KAFKA_CONTROLLER_QUORUM_VOTERS: '1@broker:29093'
KAFKA_LISTENERS: 'PLAINTEXT://broker:29092,CONTROLLER://broker:29093,PLAINTEXT_HOST://0.0.0.0:9092'
KAFKA_INTER_BROKER_LISTENER_NAME: 'PLAINTEXT'
KAFKA_CONTROLLER_LISTENER_NAMES: 'CONTROLLER'
KAFKA_LOG_DIRS: '/tmp/kraft-combined-logs'
KAFKA_CONTROLLER_QUORUM_MODE: 'kraft'
CLUSTER_ID: '4L6g3nShT-eMCtK--X86sw'

schema-registry:
image: confluentinc/cp-schema-registry:7.4.0
hostname: schema-registry
container_name: schema-registry
depends_on:
- kafka
ports:
- "8081:8081"
environment:
SCHEMA_REGISTRY_HOST_NAME: schema-registry
SCHEMA_REGISTRY_KAFKASTORE_BOOTSTRAP_SERVERS: 'broker:29092'
SCHEMA_REGISTRY_LISTENERS: http://0.0.0.0:8081
Loading

0 comments on commit b0c0a6a

Please sign in to comment.