diff --git a/.env b/.env index 485a9af..c9da293 100644 --- a/.env +++ b/.env @@ -1,2 +1,4 @@ CONFLUENT_VERSION=7.6.1 -CLUSTER_ID=bgwoWzvSSlKmk2ysynPDNg \ No newline at end of file +CLUSTER_ID=bgwoWzvSSlKmk2ysynPDNg +DB_PASSWORD=notasecret +DB_NAME=sandbox \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 6c0065f..ce9e91d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -74,6 +74,7 @@ services: environment: CONNECT_BOOTSTRAP_SERVERS: kafka1:9092,kafka2:9092,kafka3:9092 CONNECT_REST_ADVERTISED_HOST_NAME: localhost + CONNECT_REST_PORT: 8083 CONNECT_GROUP_ID: kafka-connect-sandbox CONNECT_PLUGIN_PATH: /usr/local/share/kafka/plugins CONNECT_KEY_CONVERTER: io.confluent.connect.avro.AvroConverter @@ -112,8 +113,8 @@ services: profiles: - sql environment: - MYSQL_DATABASE: sandbox - MYSQL_ROOT_PASSWORD: notasecret + MYSQL_DATABASE: ${DB_NAME} + MYSQL_ROOT_PASSWORD: ${DB_PASSWORD} ports: - "3306:3306" restart: on-failure @@ -125,8 +126,8 @@ services: profiles: - sql environment: - POSTGRES_DB: sandbox - POSTGRES_PASSWORD: notasecret + POSTGRES_DB: ${DB_NAME} + POSTGRES_PASSWORD: ${DB_PASSWORD} ports: - "5432:5432" restart: on-failure @@ -200,10 +201,12 @@ services: args: CONFLUENT_VERSION: ${CONFLUENT_VERSION} environment: - PGPASSWORD: notasecret + PGPASSWORD: ${DB_PASSWORD} + MYSQL_PWD: ${DB_PASSWORD} CLUSTER_ID: ${CLUSTER_ID} volumes: - .:/kafka-sandbox + - gradle_cache:/root/.gradle entrypoint: /bin/bash tty: true @@ -214,3 +217,4 @@ volumes: mysql_data: postgres_data: mosquitto_data: + gradle_cache: diff --git a/kafka-avro-clients/src/main/resources/producer.properties b/kafka-avro-clients/src/main/resources/producer.properties index 280106d..fe97b74 100644 --- a/kafka-avro-clients/src/main/resources/producer.properties +++ b/kafka-avro-clients/src/main/resources/producer.properties @@ -2,5 +2,5 @@ bootstrap.servers=kafka1:9092 schema.registry.url=http://schema-registry:8081 key.serializer=org.apache.kafka.common.serialization.StringSerializer value.serializer=io.confluent.kafka.serializers.KafkaAvroSerializer -acks=1 +acks=all client.id=client.producer \ No newline at end of file diff --git a/kafka-avro-union-clients/src/main/resources/producer.properties b/kafka-avro-union-clients/src/main/resources/producer.properties index 280106d..fe97b74 100644 --- a/kafka-avro-union-clients/src/main/resources/producer.properties +++ b/kafka-avro-union-clients/src/main/resources/producer.properties @@ -2,5 +2,5 @@ bootstrap.servers=kafka1:9092 schema.registry.url=http://schema-registry:8081 key.serializer=org.apache.kafka.common.serialization.StringSerializer value.serializer=io.confluent.kafka.serializers.KafkaAvroSerializer -acks=1 +acks=all client.id=client.producer \ No newline at end of file diff --git a/kafka-json-clients/src/main/resources/producer.properties b/kafka-json-clients/src/main/resources/producer.properties index 2e21f27..e9a4342 100644 --- a/kafka-json-clients/src/main/resources/producer.properties +++ b/kafka-json-clients/src/main/resources/producer.properties @@ -1,4 +1,4 @@ bootstrap.servers=kafka1:9092 key.serializer=org.apache.kafka.common.serialization.StringSerializer -acks=1 +acks=all client.id=client.producer \ No newline at end of file diff --git a/kafka-native-clients/src/main/resources/producer.properties b/kafka-native-clients/src/main/resources/producer.properties index 2e21f27..e9a4342 100644 --- a/kafka-native-clients/src/main/resources/producer.properties +++ b/kafka-native-clients/src/main/resources/producer.properties @@ -1,4 +1,4 @@ bootstrap.servers=kafka1:9092 key.serializer=org.apache.kafka.common.serialization.StringSerializer -acks=1 +acks=all client.id=client.producer \ No newline at end of file diff --git a/md/kafka-connect-database-example.md b/md/kafka-connect-database-example.md index 7269b7d..15dfdec 100644 --- a/md/kafka-connect-database-example.md +++ b/md/kafka-connect-database-example.md @@ -27,10 +27,7 @@ docker compose exec cli bash Populate it: ```bash -mysql --host=mysql --port=3306 \ - --user=root --password=notasecret \ - --database=sandbox \ - < kafka-connect/sql/customers.sql +mysql --host=mysql --database=sandbox < kafka-connect/sql/customers.sql ``` That command should have created the table `customers` and inserted 200 records. @@ -38,10 +35,7 @@ That command should have created the table `customers` and inserted 200 records. Now you can open [Adminer](http://localhost:9090) or run: ```bash -mysql --host=mysql --port=3306 \ - --user=root --password=notasecret \ - --database=sandbox \ - -e "select * from customers" +mysql --host=mysql --database=sandbox -e "select * from customers" ``` ### Create Source Connector @@ -85,9 +79,7 @@ This sink connector is going to create a table `customers` on postgres and inser Now you can open [Adminer](http://localhost:9090) or run: ```bash -psql --host=postgres --port=5432 \ - --user=postgres --dbname=sandbox\ - -c "select * from customers" +psql --host=postgres --user=postgres --dbname=sandbox -c "select * from customers" ``` List connector: