Skip to content

jingerbread/msg-service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Start kafka with zookeper, refer to kafka quickstart

Kafka should be started with default properties (zookeper port 2181, and etc)

Create custom topic "msg_output":

bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic msg_output

Run listener for this topic:

bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic msg_output --from-beginning

Run server test MessageSenderTest

In console tab for kafka listener new message should appear

Test message

Build project (skip tests if you haven't started kafka)

mvn clean install -DskipTests=true

Start message server

cd server
mvn spring-boot:run -Dserver.port=8081 -Dinstance.conf=file:conf/server.default.properties -Dlog4j.configuration=file:conf/log4j.properties

Create postgres db 'messages'

spring.datasource.url=jdbc:postgresql://localhost:5432/messages
spring.datasource.username=postgres
spring.datasource.password=postgres

Start message client

cd client
mvn spring-boot:run -Dinstance.conf=file:src/main/resources/application.properties -Dlog4j.configuration=file:conf/log4j.properties

Send some messages

curl -H "Content-Type: application/json" -X POST -d '[{"title":"Hello","text":"Hello World!","author":"User","created":"2017-10-17"}]' http://localhost:8081/api/v1/messages

response

 {"status":"SUCCESS","statusCode":0,"successful":true}

About

simple client-server app using kafka as event bus

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages