diff --git a/executor/src/main/resources/application.properties b/executor/src/main/resources/application.properties index c433a5f..fd0b450 100644 --- a/executor/src/main/resources/application.properties +++ b/executor/src/main/resources/application.properties @@ -16,8 +16,8 @@ xxl.job.executor.logpath=./logs/xxl-job/jobhandler ### xxl-job executor log-retention-days xxl.job.executor.logretentiondays=30 -kafka.consumer.servers=localhost:29092 -kafka.consumer.group.id=0 +kafka.consumer.servers=localhost:29092,localhost:39092 +kafka.consumer.group.id=gitlink-notification-group kafka.consumer.auto.offset.reset=earliest kafka.consumer.enable.auto.commit=false kafka.consumer.auto.commit.interval=100 diff --git a/middleware/.env.example b/middleware/.env.example index 3612eb7..fa85465 100644 --- a/middleware/.env.example +++ b/middleware/.env.example @@ -12,7 +12,7 @@ XXL_JOB_ADMIN_VERSION=2.3.0 MYSQL_CONTAINER_NAME=gitlink_mysql REDIS_CONTAINER_NAME=gitlink_redis XXL_JOB_ADMIN_CONTAINER_NAME=gitlink_xxl_job_admin -ZOOKEEPER_CONTAINER_NAME=gitlink_zookeepr +ZOOKEEPER_CONTAINER_NAME=gitlink_zookeeper KAFKA_CONTAINER_01_NAME=gitlink_kafka_01 KAFKA_CONTAINER_02_NAME=gitlink_kafka_02 diff --git a/middleware/services.yml b/middleware/services.yml index a28dc4b..1585c31 100644 --- a/middleware/services.yml +++ b/middleware/services.yml @@ -58,6 +58,8 @@ services: environment: ZOOKEEPER_CLIENT_PORT: 2181 ZOOKEEPER_TICK_TIME: 2000 +# volumes: +# - ${DOCKER_DATA_PATH}/zookeeper:/var/lib/zookeeper ports: - ${ZOOKEEPER_LOCAL_PORT}:2181 networks: @@ -72,10 +74,12 @@ services: - zookeeper ports: - ${KAFKA_01_LOCAL_PORT}:29092 + volumes: + - ${DOCKER_DATA_PATH}/${KAFKA_CONTAINER_01_NAME}:/var/lib/kafka environment: KAFKA_BROKER_ID: 1 KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 - KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka1:9092,PLAINTEXT_HOST://localhost:29092 + KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka1:9092,PLAINTEXT_HOST://localhost:${KAFKA_01_LOCAL_PORT} KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1 @@ -91,10 +95,12 @@ services: - zookeeper ports: - ${KAFKA_02_LOCAL_PORT}:39092 +# volumes: +# - ${DOCKER_DATA_PATH}/${KAFKA_CONTAINER_02_NAME}:/var/lib/kafka environment: KAFKA_BROKER_ID: 2 KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 - KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka2:9092,PLAINTEXT_HOST://localhost:39092 + KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka2:9092,PLAINTEXT_HOST://localhost:${KAFKA_02_LOCAL_PORT} KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1 diff --git a/writer/src/main/resources/application.yml b/writer/src/main/resources/application.yml index 134af65..a8ef998 100644 --- a/writer/src/main/resources/application.yml +++ b/writer/src/main/resources/application.yml @@ -21,21 +21,6 @@ spring: key-serializer: org.apache.kafka.common.serialization.StringSerializer #value的Serializer类,实现类实现了接口org.apache.kafka.common.serialization.Serializer value-serializer: org.apache.kafka.common.serialization.StringSerializer - #=============== consumer ======================= - consumer: - #用于标识此使用者所属的使用者组的唯一字符串 - group-id: test-consumer-group - #当Kafka中没有初始偏移量或者服务器上不再存在当前偏移量时该怎么办,默认值为latest,表示自动将偏移重置为最新的偏移量 - #可选的值为latest, earliest, none - auto-offset-reset: earliest - #消费者的偏移量将在后台定期提交,默认值为true - enable-auto-commit: true - #如果'enable-auto-commit'为true,则消费者偏移自动提交给Kafka的频率(以毫秒为单位),默认值为5000。 - auto-commit-interval: 100 - #密钥的反序列化器类,实现类实现了接口org.apache.kafka.common.serialization.Deserializer - key-deserializer: org.apache.kafka.common.serialization.StringDeserializer - #值的反序列化器类,实现类实现了接口org.apache.kafka.common.serialization.Deserializer - value-deserializer: org.apache.kafka.common.serialization.StringDeserializer datasource: # 配置数据源类型