Skip to content

kgoralski/go-kotlin-java-kafka

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About

'Hello world' Kafka integration of Java, Kotlin and Go apps

  • demo-java-source with Spring Cloud Stream - localhost:8080
  • demo-kotlin-sink with Spring Cloud Stream - localhost:8081 (Consumer)
  • demo-go-sink with Shopify/sarama (Kafka Client) - localhost:8082 (Consumer)
  • Apache Kafka as Message Broker
  • Go Http/2 Push example (just for fun)

Running Kafka from docker:

docker run --name spotifykafka -p 2181:2181 -p 9092:9092 --env ADVERTISED_HOST=localhost --env ADVERTISED_PORT=9092 spotify/kafka 

to get Shopify/sarama lib:

go get github.com/Shopify/sarama

How to run

  1. Run docker spotify/kafka
  2. Run Java/Kotlin/Go app from IDE (Prefer IDEA & Gogland)
  3. Send request to Java Source App - POST http://localhost:8080/message {"name": "Krzysztof"}
  4. Both Go and Kotlin app will print the messages on their consoles, something like this:
INFO 22360 --- [afka-listener-1] com.example.SampleSink  Kotlin received: Krzysztof
Golang received: Krzysztof

Http/2 Go Push

  1. Go 1.8beta2 required
  2. Run crypto/tls/generate_cert.go to generate cert.pem and key.pem. and put them to the project
  3. Go to https://localhost:8082/ (yes https)
  4. Resources will be pushed to browser, check Network (devtools)

References

  1. https://medium.com/@Oskarr3/implementing-cqrs-using-kafka-and-sarama-library-in-golang-da7efa3b77fe#.razrnz8eh
  2. https://blog.codecentric.de/en/2016/04/event-driven-microservices-spring-cloud-stream/
  3. Go 1.8 Http/2 Push

TODO

  1. Make it more interesting... because printing to console is not cool enough ;)
  2. Add SSE/ Websockets ?

About

'Hello world' Apache Kafka integration of Java, Kotlin and Go app (with Go Http/2 Push)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published