#!/bin/bash
-IMAGE=juplo/supersimple-consumer:1.0-SNAPSHOT
+IMAGE=juplo/simple-consumer:1.0-SNAPSHOT
if [ "$1" = "cleanup" ]
then
- docker-compose down -v
+ docker-compose down -v --remove-orphans
mvn clean
exit
fi
-docker-compose rm -svf consumer
docker-compose up -d kafka-1 kafka-2 kafka-3 cli
+docker-compose rm -svf consumer
if [[
$(docker image ls -q $IMAGE) == "" ||
"$1" = "build"
]]
then
- docker-compose rm -svf consumer
mvn clean install || exit
else
echo "Using image existing images:"
fi
docker-compose up setup
-docker-compose up -d gateway requests-1 requests-2 consumer
-
-while ! [[ $(http 0:8080/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "Waiting for gateway..."; sleep 1; done
-while ! [[ $(http 0:8081/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "Waiting for requests-1..."; sleep 1; done
-while ! [[ $(http 0:8082/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "Waiting for requests-2..."; sleep 1; done
+docker-compose up -d producer
+docker-compose ps
-echo 6 | http -v :8080/peter
+docker-compose up -d consumer
+sleep 5
+docker-compose stop consumer
-sleep 10
+docker-compose start consumer
+sleep 5
+docker-compose stop producer consumer
docker-compose logs consumer
image: juplo/toolbox
command: >
bash -c "
- kafka-topics --bootstrap-server kafka:9092 --create --if-not-exists --topic in --partitions 2 --replication-factor 3 --config min.insync.replicas=2
- kafka-topics --bootstrap-server kafka:9092 --create --if-not-exists --topic out --partitions 2 --replication-factor 3 --config min.insync.replicas=2
- kafka-topics --bootstrap-server kafka:9092 --describe --topic in
- kafka-topics --bootstrap-server kafka:9092 --describe --topic out
+ kafka-topics --bootstrap-server kafka:9092 --delete --if-exists --topic test
+ kafka-topics --bootstrap-server kafka:9092 --create --topic test --partitions 2 --replication-factor 3 --config min.insync.replicas=2
+ kafka-topics --bootstrap-server kafka:9092 --describe --topic test
"
depends_on:
- kafka-1
- kafka-2
- kafka-3
-
cli:
image: juplo/toolbox
command: sleep infinity
+ depends_on:
+ - kafka-1
+ - kafka-2
+ - kafka-3
- gateway:
- image: juplo/sumup-gateway--springified:1.0-SNAPSHOT
- ports:
- - 8080:8080
- environment:
- server.port: 8080
- spring.kafka.bootstrap-servers: kafka:9092
- spring.kafka.client-id: gateway
- sumup.gateway.topic: in
-
- requests-1:
- image: juplo/sumup-requests-json:1.0-SNAPSHOT
- ports:
- - 8081:8080
- environment:
- server.port: 8080
- sumup.requests.bootstrap-server: kafka:9092
- sumup.requests.client-id: requests-1
-
- requests-2:
- image: juplo/sumup-requests-json:1.0-SNAPSHOT
- ports:
- - 8082:8080
- environment:
- server.port: 8080
- sumup.requests.bootstrap-server: kafka:9092
- sumup.requests.client-id: requests-2
+ producer:
+ image: juplo/simple-producer:1.0-SNAPSHOT
+ command: kafka:9092 test producer
consumer:
image: juplo/supersimple-consumer:1.0-SNAPSHOT
ports:
- - 8090:8080
+ - 8080:8080
environment:
server.port: 8080
spring.kafka.bootstrap-servers: kafka:9092
- spring.kafka.producer.bootstrap-servers: kafka:9092
spring.kafak.client-id: consumer
logging.level.org.apache.kafka.clients.consumer: INFO
@Slf4j
public class Application
{
- @KafkaListener(id = "supersimple", topics = "out")
+ @KafkaListener(id = "supersimple", topics = "test")
public void recieve(String message)
{
log.info("Recieved message: {}", message);
SpringApplication.run(Application.class, args);
}
}
-// end::supersimple[]
\ No newline at end of file
+// end::supersimple[]