LIGHT

  • News
  • Docs
  • Community
  • Reddit
  • GitHub

Local Binary

Check Out

Check out the following repositories to your local working directory. I am using networknt in my home directory.

cd ~/networknt
git clone https://github.com/networknt/light-kafka.git
git clone https://github.com/networknt/light-example-4j.git

Confluent Local

Before running the tutorial, we need to have confluent platform started locally. If you are using Linux, you can install confluent locally and start it from the command line.

cd ~/tool/confluent-6.1.0/bin
confluent local services start

You can also start the confluent locally with a docker-compose.

cd ~/networknt/light-kafka
docker-compose up

Once the confluent platform is started, go to http://localhost:9021 to access the control center. Create a topic named test6 without key schema and value schema.

Start Backend

Let’s first start the ReactiveConsumer backend service within the IDE from the following folder. We will start it from the command line later.

~/networknt/light-example-4j/kafka/sidecar-backend

Start Sidecar

Start the Kafka sidecar within the IDE from the following folder.

~/networknt/kafka-sidecar

set the JVM Option to

-Dlight-4j-config-dir=config/local

Binary Value

update the config/local/values.yml to the following.

# producer format configuration
kafka-producer.keyFormat: string
kafka-producer.valueFormat: binary

# consumer format configuration
kafka-consumer.topic: test6
kafka-consumer.keyFormat: string
kafka-consumer.valueFormat: binary

# Service Startup and Shutdown Hooks
service.com.networknt.server.StartupHookProvider:
  - com.networknt.mesh.kafka.ProducerStartupHook
  # - com.networknt.mesh.kafka.ActiveConsumerStartupHook
  # - com.networknt.mesh.kafka.KsqldbConsumerStartupHook
  - com.networknt.mesh.kafka.ReactiveConsumerStartupHook
  # - com.networknt.mesh.kafka.AdminClientStartupHook
service.com.networknt.server.ShutdownHookProvider:
  - com.networknt.mesh.kafka.ProducerShutdownHook
  # - com.networknt.mesh.kafka.ActiveConsumerShutdownHook
  # - com.networknt.mesh.kafka.KsqldbConsumerShutdownHook
  - com.networknt.mesh.kafka.ReactiveConsumerShutdownHook
  # - com.networknt.mesh.kafka.AdminClientShutdownHook


Curl command line.

curl -k --location --request POST 'https://localhost:8443/producers/test6' \
--header 'Content-Type: application/json' \
--data-raw '{"records":[{"key":"alice","value":"YWJj"},{"key":"john","value":"ZGVm"},{"key":"alex","value":"eHl6"}]}'

Binary Key

Update the config/local/values.yml to the following.


# producer format configuration
kafka-producer.keyFormat: binary
kafka-producer.valueFormat: string

# consumer format configuration
kafka-consumer.topic: test6
kafka-consumer.keyFormat: binary
kafka-consumer.valueFormat: string

# Service Startup and Shutdown Hooks
service.com.networknt.server.StartupHookProvider:
  - com.networknt.mesh.kafka.ProducerStartupHook
  # - com.networknt.mesh.kafka.ActiveConsumerStartupHook
  # - com.networknt.mesh.kafka.KsqldbConsumerStartupHook
  - com.networknt.mesh.kafka.ReactiveConsumerStartupHook
  # - com.networknt.mesh.kafka.AdminClientStartupHook
service.com.networknt.server.ShutdownHookProvider:
  - com.networknt.mesh.kafka.ProducerShutdownHook
  # - com.networknt.mesh.kafka.ActiveConsumerShutdownHook
  # - com.networknt.mesh.kafka.KsqldbConsumerShutdownHook
  - com.networknt.mesh.kafka.ReactiveConsumerShutdownHook
  # - com.networknt.mesh.kafka.AdminClientShutdownHook

Command Line

We are going to start both Kafka Sidecar and the sidecar-backend with the command line and run the curl command from the command line to test the sidecar.

Docker Compose

The easy way to get the Kafka-sidecar and backend API started together is the docker-compose-demo.yml in the Kafka-sidecar repo.

Checkout kafka-sidecar and start the confluent platform with docker-compose.

cd ~/networknt
git clone https://github.com/networknt/kafka-sidecar.git
cd ~/networknt/kafka-sidecar
docker-compose up -d

Start the kafka sidecar and backend API with another docker-compose with host network.

cd ~/networknt/kafka-sidecar
docker-compose -f docker-compose-demo.yml up

Create a topic test6 and dead letter topic test6.dlq from the control center and send a test request with curl.


curl -k --location --request POST 'https://localhost:8443/producers/test6' \
--header 'Content-Type: application/json' \
--data-raw '{"records":[{"key":"YWxpY2U=","value":"abc"},{"key":"am9obg==","value":"def"},{"key":"YWxleA==","value":"xyz"}]}'

You should see the logs in the docker-compose-demo console for the new messages.

The following is a video tutorial, and please ignore the DOCKER_HOST_IP set up in the demo as it is not necessary with the host network.

Kubernetes

  • About Light
    • Overview
    • Testimonials
    • What is Light
    • Features
    • Principles
    • Benefits
    • Roadmap
    • Community
    • Articles
    • Videos
    • License
    • Why Light Platform
  • Getting Started
    • Get Started Overview
    • Environment
    • Light Codegen Tool
    • Light Rest 4j
    • Light Tram 4j
    • Light Graphql 4j
    • Light Hybrid 4j
    • Light Eventuate 4j
    • Light Oauth2
    • Light Portal Service
    • Light Proxy Server
    • Light Router Server
    • Light Config Server
    • Light Saga 4j
    • Light Session 4j
    • Webserver
    • Websocket
    • Spring Boot Servlet
  • Architecture
    • Architecture Overview
    • API Category
    • API Gateway
    • Architecture Patterns
    • CQRS
    • Eco System
    • Event Sourcing
    • Fail Fast vs Fail Slow
    • Integration Patterns
    • JavaEE declining
    • Key Distribution
    • Microservices Architecture
    • Microservices Monitoring
    • Microservices Security
    • Microservices Traceability
    • Modular Monolith
    • Platform Ecosystem
    • Plugin Architecture
    • Scalability and Performance
    • Serverless
    • Service Collaboration
    • Service Mesh
    • SOA
    • Spring is bloated
    • Stages of API Adoption
    • Transaction Management
    • Microservices Cross-cutting Concerns Options
    • Service Mesh Plus
    • Service Discovery
  • Design
    • Design Overview
    • Design First vs Code First
    • Desgin Pattern
    • Service Evolution
    • Consumer Contract and Consumer Driven Contract
    • Handling Partial Failure
    • Idempotency
    • Server Life Cycle
    • Environment Segregation
    • Database
    • Decomposition Patterns
    • Http2
    • Test Driven
    • Multi-Tenancy
    • Why check token expiration
    • WebServices to Microservices
  • Cross-Cutting Concerns
    • Concerns Overview
  • API Styles
    • Light-4j for absolute performance
    • Style Overview
    • Distributed session on IMDG
    • Hybrid Serverless Modularized Monolithic
    • Kafka - Event Sourcing and CQRS
    • REST - Representational state transfer
    • Web Server with Light
    • Websocket with Light
    • Spring Boot Integration
    • Single Page Application
    • GraphQL - A query language for your API
    • Light IBM MQ
    • Light AWS Lambda
    • Chaos Monkey
  • Infrastructure Services
    • Service Overview
    • Light Proxy
    • Light Mesh
    • Light Router
    • Light Portal
    • Messaging Infrastructure
    • Centralized Logging
    • COVID-19
    • Light OAuth2
    • Metrics and Alerts
    • Config Server
    • Tokenization
    • Light Controller
  • Tool Chain
    • Tool Chain Overview
  • Utility Library
  • Service Consumer
    • Service Consumer
  • Development
    • Development Overview
  • Deployment
    • Deployment Overview
    • Frontend Backend
    • Linux Service
    • Windows Service
    • Install Eventuate on Windows
    • Secure API
    • Client vs light-router
    • Memory Limit
    • Deploy to Kubernetes
  • Benchmark
    • Benchmark Overview
  • Tutorial
    • Tutorial Overview
  • Troubleshooting
    • Troubleshoot
  • FAQ
    • FAQ Overview
  • Milestones
  • Contribute
    • Contribute to Light
    • Development
    • Documentation
    • Example
    • Tutorial
“Local Binary” was last updated: September 13, 2021: update kafka sidecar local binary (bdc4a1b)
Improve this page
  • News
  • Docs
  • Community
  • Reddit
  • GitHub
  • About Light
  • Getting Started
  • Architecture
  • Design
  • Cross-Cutting Concerns
  • API Styles
  • Infrastructure Services
  • Tool Chain
  • Utility Library
  • Service Consumer
  • Development
  • Deployment
  • Benchmark
  • Tutorial
  • Troubleshooting
  • FAQ
  • Milestones
  • Contribute