Coder Social home page Coder Social logo

kafka-msk-serverless-kotlin-tutorial's Introduction

kafka-msk-serverless-kotlin-tutorial

This is a simple Kafka Producer Consumer example which connects to AWS MSK Serverless cluster.

How to build

./gradlew clean build

How to locally run the application

AWS MSK Serverless is not open to public. Unless we set up a bastion host, we can't really connect to the cluster from our local machine.

So for local development, we use single node confluent kafka broker using docker.

To run the kafka server locally docker-compose up -d

To stop the kafka server locally docker-compose down

For accessing confluent local center http://localhost:9021/

If you are using glue schema registry, then make sure setting the aws creds.

To run the app in development profile (connecting to local kafka)

java -jar build/libs/kafka-msk-serverless-kotlin-tutorial-0.0.1-SNAPSHOT.jar --spring.profiles.active=development

How to run the application in an aws hosted environment

The service can be deployed in AWS AppRunner or EC2. Make sure you set the correct environment variables, VPC and IAM policies.

For more details, follow the tutorial.

Application Properties

Either set the following environment variables

  • BOOTSTRAP_URL

  • AWS_REGION

  • TOPIC_SIMPLE_NAME

  • TOPIC_SIMPLE_GROUP

  • TOPIC_BOOKCLUB_NAME

  • TOPIC_BOOKCLUB_GROUP

  • TOPIC_BOOKCLUB_REGISTRY

  • TOPIC_BOOKCLUB_SCHEMA

OR update the properties in resources/application.yml

To Run

java -jar build/libs/kafka-msk-serverless-kotlin-tutorial-0.0.1-SNAPSHOT.jar -Xms256m .

REST Services

(for local server the endpoint.url would be http://localhost:9092)

To list the existing topics

GET https://<endpoint.url>/admin/topic/all

To create a new topic

POST https://<endpoint.url>/admin/topic

with topic name in the body msk-serverless-tutorial-topic-simple

msk-serverless-tutorial-topic-bookclub

Once the topics are created, make sure to start the consumers

POST https://<endpoint.url>/admin/consumers/start

To send a simple message

This will produce a simple text message to topic msk-serverless-tutorial-topic-simple. Endpoint: POST https://<endpoint.url>/message/simple

with a String message body This is a simple message

To send a bookclub record

This will produce a bookclub record serialised with avro schema TOPIC_BOOKCLUB_SCHEMA created in glue registry. Endpoint: POST https://<endpoint.url>/message/bookclub With body

{
    "name": "Runaway",
    "author": "Alice Munro",
    "genre": "Short Stories",
    "rating": "4"
}

kafka-msk-serverless-kotlin-tutorial's People

Contributors

jkumaranc avatar

Watchers

 avatar

Forkers

digio

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.