samples cleanup
This commit is contained in:
@@ -1,18 +0,0 @@
|
||||
version: '2'
|
||||
services:
|
||||
kafka:
|
||||
image: wurstmeister/kafka
|
||||
ports:
|
||||
- "9092:9092"
|
||||
environment:
|
||||
- KAFKA_ADVERTISED_HOST_NAME=127.0.0.1
|
||||
- KAFKA_ADVERTISED_PORT=9092
|
||||
- KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181
|
||||
depends_on:
|
||||
- zookeeper
|
||||
zookeeper:
|
||||
image: wurstmeister/zookeeper
|
||||
ports:
|
||||
- "2181:2181"
|
||||
environment:
|
||||
- KAFKA_ADVERTISED_HOST_NAME=zookeeper
|
||||
@@ -1,13 +0,0 @@
|
||||
version: '2'
|
||||
volumes:
|
||||
data-volume: {}
|
||||
services:
|
||||
mysql:
|
||||
image: mariadb
|
||||
ports:
|
||||
- "3306:3306"
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: pwd
|
||||
MYSQL_DATABASE: sample_mysql_db
|
||||
volumes:
|
||||
- data-volume:/var/lib/mysql
|
||||
@@ -23,19 +23,16 @@ To run this sample, you will need to have installed:
|
||||
|
||||
The following instructions assume that you are running Kafka and MySql as Docker images.
|
||||
|
||||
* Go to the root of the repository
|
||||
* `cd kafka-docker`
|
||||
* Go to the application root
|
||||
* `docker-compose up -d`
|
||||
|
||||
* Open another terminal and go to the root of the samples repository
|
||||
* `cd mysql-docker`
|
||||
* `docker-compose up -d`
|
||||
* Open another terminal
|
||||
* Ensure that you have the `mysql` CLI tool installed and then use this command:
|
||||
`mysql -u root -p -h 127.0.0.1 -P 3306 sample_mysql_db`
|
||||
|
||||
`sample_mysql_db` is the name of the database created by the mysql that is running in the docker container.
|
||||
|
||||
* Open another terminal and go the root of this sample app (`source`)
|
||||
* Go back to the other terminal (root of this sample app `sink`)
|
||||
* `./mvnw clean package`
|
||||
|
||||
When you start the app, it will create a table in the database.
|
||||
@@ -46,6 +43,7 @@ See the method annotated with`PostConstruct` in the application for more details
|
||||
The application has a convenient test source that sends to the same destination on the broker where the sink consumes data from.
|
||||
This test source will send some test records every second.
|
||||
Alternatively, you can connect to the topic using a Kafka console producer and send data in the format - `{"id":1,"name":"Bob","tag":"1}`.
|
||||
If you go with this kafka console producer approach, make sure you comment out the test source in the sample and rebuild.
|
||||
|
||||
* Now go to your MySQL CLI:
|
||||
|
||||
|
||||
29
sink/docker-compose.yml
Normal file
29
sink/docker-compose.yml
Normal file
@@ -0,0 +1,29 @@
|
||||
version: '2'
|
||||
volumes:
|
||||
data-volume: {}
|
||||
services:
|
||||
mysql:
|
||||
image: mariadb
|
||||
ports:
|
||||
- "3306:3306"
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: pwd
|
||||
MYSQL_DATABASE: sample_mysql_db
|
||||
volumes:
|
||||
- data-volume:/var/lib/mysql
|
||||
kafka:
|
||||
image: wurstmeister/kafka
|
||||
ports:
|
||||
- "9092:9092"
|
||||
environment:
|
||||
- KAFKA_ADVERTISED_HOST_NAME=127.0.0.1
|
||||
- KAFKA_ADVERTISED_PORT=9092
|
||||
- KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181
|
||||
depends_on:
|
||||
- zookeeper
|
||||
zookeeper:
|
||||
image: wurstmeister/zookeeper
|
||||
ports:
|
||||
- "2181:2181"
|
||||
environment:
|
||||
- KAFKA_ADVERTISED_HOST_NAME=zookeeper
|
||||
@@ -35,19 +35,16 @@ Refer to the `application.yml` for the defaults used for the following propertie
|
||||
|
||||
The following instructions assume that you are running Kafka and MySql as Docker images.
|
||||
|
||||
* Go to the root of the repository
|
||||
* `cd kafka-docker`
|
||||
* Go to the application root
|
||||
* `docker-compose up -d`
|
||||
|
||||
* Open another terminal and go to the root of the samples repository
|
||||
* `cd mysql-docker`
|
||||
* `docker-compose up -d`
|
||||
* Open another terminal
|
||||
* Ensure that you have the `mysql` CLI tool installed and then use this command:
|
||||
`mysql -u root -p -h 127.0.0.1 -P 3306 sample_mysql_db`
|
||||
|
||||
`sample_mysql_db` is the name of the database created by the mysql that is running in the docker container.
|
||||
|
||||
* Open another terminal and go the root of this sample app (`source`)
|
||||
* Go back to the other terminal (root of this sample app `source`)
|
||||
* `./mvnw clean package`
|
||||
|
||||
When you start the app, it will insert some test data into the database.
|
||||
|
||||
29
source/docker-compose.yml
Normal file
29
source/docker-compose.yml
Normal file
@@ -0,0 +1,29 @@
|
||||
version: '2'
|
||||
volumes:
|
||||
data-volume: {}
|
||||
services:
|
||||
mysql:
|
||||
image: mariadb
|
||||
ports:
|
||||
- "3306:3306"
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: pwd
|
||||
MYSQL_DATABASE: sample_mysql_db
|
||||
volumes:
|
||||
- data-volume:/var/lib/mysql
|
||||
kafka:
|
||||
image: wurstmeister/kafka
|
||||
ports:
|
||||
- "9092:9092"
|
||||
environment:
|
||||
- KAFKA_ADVERTISED_HOST_NAME=127.0.0.1
|
||||
- KAFKA_ADVERTISED_PORT=9092
|
||||
- KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181
|
||||
depends_on:
|
||||
- zookeeper
|
||||
zookeeper:
|
||||
image: wurstmeister/zookeeper
|
||||
ports:
|
||||
- "2181:2181"
|
||||
environment:
|
||||
- KAFKA_ADVERTISED_HOST_NAME=zookeeper
|
||||
2
source/start-kafka-shell.sh
Executable file
2
source/start-kafka-shell.sh
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -e HOST_IP=$1 -e ZK=$2 -i -t wurstmeister/kafka /bin/bash
|
||||
Reference in New Issue
Block a user