From 530001a0bf6bcd641a31a9d092242a41065bdece Mon Sep 17 00:00:00 2001 From: 3y Date: Wed, 3 Aug 2022 20:09:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9&&=E8=A7=84=E8=8C=83=20?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 8 +- .../austin/cron/xxl/config/XxlJobConfig.java | 2 +- .../receiver/eventbus/EventBusReceiver.java | 2 +- .../handler/receiver/kafka/Receiver.java | 2 +- .../handler/receiver/kafka/ReceiverStart.java | 2 +- .../rocketmq/RocketMqBizReceiver.java | 4 +- .../rocketmq/RocketMqRecallReceiver.java | 4 +- .../eventbus/EventBusSendMqServiceImpl.java | 2 +- .../mq/kafka/KafkaSendMqServiceImpl.java | 2 +- .../mq/rabbit/RabbitSendMqServiceImpl.java | 2 +- .../rocketmq/RocketMqSendMqServiceImpl.java | 2 +- .../java3y/austin/support/utils/LogUtils.java | 21 ++--- .../com/java3y/austin/AustinApplication.java | 2 +- .../src/main/resources/application.properties | 88 +++++++++---------- docker/Dockerfile | 2 +- 15 files changed, 70 insertions(+), 75 deletions(-) diff --git a/README.md b/README.md index 2c7d5c0..18b2d62 100644 --- a/README.md +++ b/README.md @@ -72,9 +72,9 @@ austin项目**核心流程**:`austin-api`接收到发送消息请求,直接 **3**、执行`sql`文件夹下的`austin.sql`创建对应的表以及插入测试数据 -**4**、如果配置`austin-mq-pipeline=kafka`,需要填写`application.properties`中`austin-kafka`对应的`ip`/`port`信息 +**4**、如果配置`austin.mq.pipeline=kafka`,需要填写`application.properties`中`austin.kafka`对应的`ip`/`port`信息 -**5**、填写`application.properties`中`austin-redis`对应的`ip`/`port`信息 +**5**、填写`application.properties`中`austin.redis`对应的`ip`/`port`信息 **6**、检查消息队列topic:`austin.business.topic.name`(我的topicName为:austinBusiness) @@ -100,9 +100,9 @@ curl -XPOST "127.0.0.1:8080/send" -H 'Content-Type: application/json' -d '{"co **12**、正常使用**数据管理**(查看实时数据链路下发)需要将`austin-stream`的`jar`包上传至`Flink`,根据[部署文档](INSTALL.md)启动Flink。在打`jar`包前需要填写`com.java3y.austin.stream.constants.AustinFlinkConstant`中的`redis`和`kafka`的`ip/port`(注:日志的topic在`application.properties`中的`austin.business.log.topic.name`。如果没有该topic,需要提前创建,并使用Kafka作为消息队列实现) -**13**、正常使用**定时任务**需要部署`xxl-job`,根据[部署文档](INSTALL.md)启动xxl的调度中心,并在`application.properteis`中填写 `austin-xxl-job-ip`和`austin-xxl-job-port` +**13**、正常使用**定时任务**需要部署`xxl-job`,根据[部署文档](INSTALL.md)启动xxl的调度中心,并在`application.properteis`中填写 `austin.xxl.job.ip`和`austin.xxl.job.port` -**14**、正常使用**分布式日志采集**需要部署`graylog`,根据[部署文档](INSTALL.md)启动`graylog`,并在`application.properteis`中填写 `austin-grayLog-ip` +**14**、正常使用**分布式日志采集**需要部署`graylog`,根据[部署文档](INSTALL.md)启动`graylog`,并在`application.properteis`中填写 `austin.grayLog.ip` **14**、正常使用**系统监控**需要部署`promethus`和`grafana`,根据[部署文档](INSTALL.md)配置`grafana`图表 diff --git a/austin-cron/src/main/java/com/java3y/austin/cron/xxl/config/XxlJobConfig.java b/austin-cron/src/main/java/com/java3y/austin/cron/xxl/config/XxlJobConfig.java index 981abf9..6286868 100644 --- a/austin-cron/src/main/java/com/java3y/austin/cron/xxl/config/XxlJobConfig.java +++ b/austin-cron/src/main/java/com/java3y/austin/cron/xxl/config/XxlJobConfig.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; */ @Slf4j @Configuration -@ConditionalOnProperty(name = "xxl-job.enabled",havingValue = "true") +@ConditionalOnProperty(name = "austin.xxl.job.enabled",havingValue = "true") public class XxlJobConfig { @Value("${xxl.job.admin.addresses}") diff --git a/austin-handler/src/main/java/com/java3y/austin/handler/receiver/eventbus/EventBusReceiver.java b/austin-handler/src/main/java/com/java3y/austin/handler/receiver/eventbus/EventBusReceiver.java index fdde8e7..e996361 100644 --- a/austin-handler/src/main/java/com/java3y/austin/handler/receiver/eventbus/EventBusReceiver.java +++ b/austin-handler/src/main/java/com/java3y/austin/handler/receiver/eventbus/EventBusReceiver.java @@ -16,7 +16,7 @@ import java.util.List; * @author 3y */ @Component -@ConditionalOnProperty(name = "austin-mq-pipeline", havingValue = MessageQueuePipeline.EVENT_BUS) +@ConditionalOnProperty(name = "austin.mq.pipeline", havingValue = MessageQueuePipeline.EVENT_BUS) public class EventBusReceiver implements EventBusListener { @Autowired diff --git a/austin-handler/src/main/java/com/java3y/austin/handler/receiver/kafka/Receiver.java b/austin-handler/src/main/java/com/java3y/austin/handler/receiver/kafka/Receiver.java index c29a1cf..b9c41d4 100644 --- a/austin-handler/src/main/java/com/java3y/austin/handler/receiver/kafka/Receiver.java +++ b/austin-handler/src/main/java/com/java3y/austin/handler/receiver/kafka/Receiver.java @@ -36,7 +36,7 @@ import java.util.Optional; @Slf4j @Component @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) -@ConditionalOnProperty(name = "austin-mq-pipeline", havingValue = MessageQueuePipeline.KAFKA) +@ConditionalOnProperty(name = "austin.mq.pipeline", havingValue = MessageQueuePipeline.KAFKA) public class Receiver { @Autowired private ConsumeService consumeService; diff --git a/austin-handler/src/main/java/com/java3y/austin/handler/receiver/kafka/ReceiverStart.java b/austin-handler/src/main/java/com/java3y/austin/handler/receiver/kafka/ReceiverStart.java index 01887ae..49bd953 100644 --- a/austin-handler/src/main/java/com/java3y/austin/handler/receiver/kafka/ReceiverStart.java +++ b/austin-handler/src/main/java/com/java3y/austin/handler/receiver/kafka/ReceiverStart.java @@ -31,7 +31,7 @@ import java.util.Optional; * @date 2021/12/4 */ @Service -@ConditionalOnProperty(name = "austin-mq-pipeline", havingValue = MessageQueuePipeline.KAFKA) +@ConditionalOnProperty(name = "austin.mq.pipeline", havingValue = MessageQueuePipeline.KAFKA) @Slf4j public class ReceiverStart { diff --git a/austin-handler/src/main/java/com/java3y/austin/handler/receiver/rocketmq/RocketMqBizReceiver.java b/austin-handler/src/main/java/com/java3y/austin/handler/receiver/rocketmq/RocketMqBizReceiver.java index 92e4efb..c0755a6 100644 --- a/austin-handler/src/main/java/com/java3y/austin/handler/receiver/rocketmq/RocketMqBizReceiver.java +++ b/austin-handler/src/main/java/com/java3y/austin/handler/receiver/rocketmq/RocketMqBizReceiver.java @@ -21,9 +21,9 @@ import java.util.List; * create date: 2022/7/16 */ @Component -@ConditionalOnProperty(name = "austin-mq-pipeline", havingValue = MessageQueuePipeline.ROCKET_MQ) +@ConditionalOnProperty(name = "austin.mq.pipeline", havingValue = MessageQueuePipeline.ROCKET_MQ) @RocketMQMessageListener(topic = "${austin.business.topic.name}", - consumerGroup = "${austin-rocketmq-biz-consumer-group}", + consumerGroup = "${austin.rocketmq.biz.consumer.group}", selectorType = SelectorType.TAG, selectorExpression = "${austin.business.tagId.value}" ) diff --git a/austin-handler/src/main/java/com/java3y/austin/handler/receiver/rocketmq/RocketMqRecallReceiver.java b/austin-handler/src/main/java/com/java3y/austin/handler/receiver/rocketmq/RocketMqRecallReceiver.java index aebacd0..66eeb31 100644 --- a/austin-handler/src/main/java/com/java3y/austin/handler/receiver/rocketmq/RocketMqRecallReceiver.java +++ b/austin-handler/src/main/java/com/java3y/austin/handler/receiver/rocketmq/RocketMqRecallReceiver.java @@ -19,9 +19,9 @@ import org.springframework.stereotype.Component; * create date: 2022/7/16 */ @Component -@ConditionalOnProperty(name = "austin-mq-pipeline", havingValue = MessageQueuePipeline.ROCKET_MQ) +@ConditionalOnProperty(name = "austin.mq.pipeline", havingValue = MessageQueuePipeline.ROCKET_MQ) @RocketMQMessageListener(topic = "${austin.business.recall.topic.name}", - consumerGroup = "${austin-rocketmq-recall-consumer-group}", + consumerGroup = "${austin.rocketmq.recall.consumer.group}", selectorType = SelectorType.TAG, selectorExpression = "${austin.business.tagId.value}" ) diff --git a/austin-support/src/main/java/com/java3y/austin/support/mq/eventbus/EventBusSendMqServiceImpl.java b/austin-support/src/main/java/com/java3y/austin/support/mq/eventbus/EventBusSendMqServiceImpl.java index 38d5152..5162178 100644 --- a/austin-support/src/main/java/com/java3y/austin/support/mq/eventbus/EventBusSendMqServiceImpl.java +++ b/austin-support/src/main/java/com/java3y/austin/support/mq/eventbus/EventBusSendMqServiceImpl.java @@ -20,7 +20,7 @@ import org.springframework.stereotype.Service; */ @Slf4j @Service -@ConditionalOnProperty(name = "austin-mq-pipeline", havingValue = MessageQueuePipeline.EVENT_BUS) +@ConditionalOnProperty(name = "austin.mq.pipeline", havingValue = MessageQueuePipeline.EVENT_BUS) public class EventBusSendMqServiceImpl implements SendMqService { private EventBus eventBus = new EventBus(); diff --git a/austin-support/src/main/java/com/java3y/austin/support/mq/kafka/KafkaSendMqServiceImpl.java b/austin-support/src/main/java/com/java3y/austin/support/mq/kafka/KafkaSendMqServiceImpl.java index 8f0398b..d8b62d5 100644 --- a/austin-support/src/main/java/com/java3y/austin/support/mq/kafka/KafkaSendMqServiceImpl.java +++ b/austin-support/src/main/java/com/java3y/austin/support/mq/kafka/KafkaSendMqServiceImpl.java @@ -24,7 +24,7 @@ import java.util.List; */ @Slf4j @Service -@ConditionalOnProperty(name = "austin-mq-pipeline", havingValue = MessageQueuePipeline.KAFKA) +@ConditionalOnProperty(name = "austin.mq.pipeline", havingValue = MessageQueuePipeline.KAFKA) public class KafkaSendMqServiceImpl implements SendMqService { @Autowired diff --git a/austin-support/src/main/java/com/java3y/austin/support/mq/rabbit/RabbitSendMqServiceImpl.java b/austin-support/src/main/java/com/java3y/austin/support/mq/rabbit/RabbitSendMqServiceImpl.java index 661f4b7..6e4057b 100644 --- a/austin-support/src/main/java/com/java3y/austin/support/mq/rabbit/RabbitSendMqServiceImpl.java +++ b/austin-support/src/main/java/com/java3y/austin/support/mq/rabbit/RabbitSendMqServiceImpl.java @@ -16,7 +16,7 @@ import org.springframework.stereotype.Service; */ @Slf4j @Service -@ConditionalOnProperty(name = "austin-mq-pipeline", havingValue = MessageQueuePipeline.RABBIT_MQ) +@ConditionalOnProperty(name = "austin.mq.pipeline", havingValue = MessageQueuePipeline.RABBIT_MQ) public class RabbitSendMqServiceImpl implements SendMqService { @Autowired diff --git a/austin-support/src/main/java/com/java3y/austin/support/mq/rocketmq/RocketMqSendMqServiceImpl.java b/austin-support/src/main/java/com/java3y/austin/support/mq/rocketmq/RocketMqSendMqServiceImpl.java index 3749ee9..7caa3ea 100644 --- a/austin-support/src/main/java/com/java3y/austin/support/mq/rocketmq/RocketMqSendMqServiceImpl.java +++ b/austin-support/src/main/java/com/java3y/austin/support/mq/rocketmq/RocketMqSendMqServiceImpl.java @@ -18,7 +18,7 @@ import org.springframework.stereotype.Service; */ @Slf4j @Service -@ConditionalOnProperty(name = "austin-mq-pipeline", havingValue = MessageQueuePipeline.ROCKET_MQ) +@ConditionalOnProperty(name = "austin.mq.pipeline", havingValue = MessageQueuePipeline.ROCKET_MQ) public class RocketMqSendMqServiceImpl implements SendMqService { @Autowired diff --git a/austin-support/src/main/java/com/java3y/austin/support/utils/LogUtils.java b/austin-support/src/main/java/com/java3y/austin/support/utils/LogUtils.java index 1b542d1..6172227 100644 --- a/austin-support/src/main/java/com/java3y/austin/support/utils/LogUtils.java +++ b/austin-support/src/main/java/com/java3y/austin/support/utils/LogUtils.java @@ -6,7 +6,7 @@ import com.alibaba.fastjson.JSON; import com.google.common.base.Throwables; import com.java3y.austin.common.domain.AnchorInfo; import com.java3y.austin.common.domain.LogParam; -import com.java3y.austin.support.constans.MessageQueuePipeline; +import com.java3y.austin.support.mq.SendMqService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -22,11 +22,8 @@ import org.springframework.stereotype.Component; @Component public class LogUtils extends CustomLogListener { - @Value("${austin-mq-pipeline}") - private String mqPipeline; - @Autowired - private KafkaTemplate kafkaTemplate; + private SendMqService sendMqService; @Value("${austin.business.log.topic.name}") private String topicName; @@ -54,15 +51,13 @@ public class LogUtils extends CustomLogListener { anchorInfo.setTimestamp(System.currentTimeMillis()); String message = JSON.toJSONString(anchorInfo); log.info(message); - if (MessageQueuePipeline.KAFKA.equals(mqPipeline)) { - try { - kafkaTemplate.send(topicName, message); - } catch (Exception e) { - log.error("LogUtils#print kafka fail! e:{},params:{}", Throwables.getStackTraceAsString(e) - , JSON.toJSONString(anchorInfo)); - } - } + try { + sendMqService.send(topicName, message); + } catch (Exception e) { + log.error("LogUtils#print send mq fail! e:{},params:{}", Throwables.getStackTraceAsString(e) + , JSON.toJSONString(anchorInfo)); + } } /** diff --git a/austin-web/src/main/java/com/java3y/austin/AustinApplication.java b/austin-web/src/main/java/com/java3y/austin/AustinApplication.java index f3283be..0cfc723 100644 --- a/austin-web/src/main/java/com/java3y/austin/AustinApplication.java +++ b/austin-web/src/main/java/com/java3y/austin/AustinApplication.java @@ -15,7 +15,7 @@ public class AustinApplication { * TODO 【optional】 * 如果你需要动态配置 * 1、启动apollo - * 2、将application.properties配置文件的 apollo.enabled 改为true + * 2、将application.properties配置文件的 austin.apollo.enabled 改为true * 3、下方的property替换真实的ip和port */ System.setProperty("apollo.config-service", "http://ip:port"); diff --git a/austin-web/src/main/resources/application.properties b/austin-web/src/main/resources/application.properties index 860c299..23d01a7 100644 --- a/austin-web/src/main/resources/application.properties +++ b/austin-web/src/main/resources/application.properties @@ -3,41 +3,42 @@ # TODO please replace 【must】 config value # todo [database] ip/port/username/password 【must】 -austin-database-ip=localhost -austin-database-port=3306 -austin-database-username=root -austin-database-password=root123_A +austin.database.ip=localhost +austin.database.port=3306 +austin.database.username=root +austin.database.password=root123_A # todo [redis] ip/port/password【must】 -austin-redis-ip=localhost -austin-redis-port=5003 -austin-redis-password=austin +austin.redis.ip=localhost +austin.redis.port=5003 +austin.redis.password=austin -# TODO choose : kafka/eventBus/rocketMq/rabbitMq -austin-mq-pipeline=eventBus +# TODO choose : kafka/eventBus/rocketMq/rabbitMq, default eventBus +austin.mq.pipeline=eventBus -# todo [kafka] ip/port【optional】, if austin-mq-pipeline=kafka 【must】 -austin-kafka-ip= -austin-kafka-port= +# todo [kafka] ip/port【optional】, if austin.mq.pipeline=kafka 【must】 +austin.kafka.ip= +austin.kafka.port= -# todo [rocketMq] 【optional】, if austin-mq-pipeline=rocketMq【must】 -austin-rocketmq-nameserver-ip= -austin-rocketmq-nameserver-port= +# todo [rocketMq] 【optional】, if austin.mq.pipeline=rocketMq【must】 +austin.rocketmq.nameserver.ip= +austin.rocketmq.nameserver.port= -# todo [rabbitMq] 【optional】, if austin-mq-pipeline=rabbitMq【must】 -austin-rabbitmq-ip= -austin-rabbitmq-port= +# todo [rabbitMq] 【optional】, if austin.mq.pipeline=rabbitMq【must】 +austin.rabbitmq.ip= +austin.rabbitmq.port= -# todo [xxl-job] switch/ip/port/【optional】 -xxl-job.enabled=false -austin-xxl-job-ip=127.0.0.1 -austin-xxl-job-port=6767 +# todo [xxl-job] switch 【optional】, if austin.xxl.job.enabled=true 【must】 +austin.xxl.job.enabled=false +austin.xxl.job.ip=127.0.0.1 +austin.xxl.job.port=6767 -# todo [apollo] switch 【optional】 -apollo.enabled=false +# todo choose: apollo/nacos switch 【optional】 ,if apollo and nacos both false, use local.properties +austin.apollo.enabled=false +austin.nacos.enabled=false # todo [grayLog] ip 【optional】 -austin-grayLog-ip=127.0.0.1 +austin.grayLog.ip=127.0.0.1 ##################### system properties ##################### server.shutdown=graceful @@ -45,13 +46,13 @@ server.shutdown=graceful ##################### database properties ##################### # notice:mysql version 5.7x !!! -spring.datasource.url=jdbc:mysql://${austin-database-ip}:${austin-database-port}/austin?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&zeroDateTimeBehavior=convertToNull -spring.datasource.username=${austin-database-username} -spring.datasource.password=${austin-database-password} +spring.datasource.url=jdbc:mysql://${austin.database.ip}:${austin.database.port}/austin?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&zeroDateTimeBehavior=convertToNull +spring.datasource.username=${austin.database.username} +spring.datasource.password=${austin.database.password} spring.datasource.driver-class-name=com.mysql.jdbc.Driver ##################### kafka properties ##################### -spring.kafka.bootstrap-servers=${austin-kafka-ip}:${austin-kafka-port} +spring.kafka.bootstrap-servers=${austin.kafka.ip}:${austin.kafka.port} spring.kafka.producer.key-serializer=org.apache.kafka.common.serialization.StringSerializer spring.kafka.producer.value-serializer=org.apache.kafka.common.serialization.StringSerializer spring.kafka.consumer.key-deserializer=org.apache.kafka.common.serialization.StringDeserializer @@ -62,18 +63,18 @@ spring.kafka.consumer.enable-auto-commit=true ##################### rocketmq properties ##################### -rocketmq.name-server=${austin-rocketmq-nameserver-ip}:${austin-rocketmq-nameserver-port} +rocketmq.name-server=${austin.rocketmq.nameserver.ip}:${austin.rocketmq.nameserver.port} rocketmq.producer.group=unique-producer-group -austin-rocketmq-biz-consumer-group=unique-biz-consumer-group -austin-rocketmq-recall-consumer-group=unique-recall-consumer-group +austin.rocketmq.biz.consumer.group=unique-biz-consumer-group +austin.rocketmq.recall.consumer.group=unique-recall-consumer-group ##################### Rabbit properties ##################### #RabbitMq所在服务器IP -spring.rabbitmq.host=${austin-rabbitmq-ip} +spring.rabbitmq.host=${austin.rabbitmq.ip} #连接端口号 -spring.rabbitmq.port=${austin-rabbitmq-port} +spring.rabbitmq.port=${austin.rabbitmq.port} server.port=8080 spring.application.name=cl @@ -90,16 +91,16 @@ austin.rabbitmq.topic.name=austinRabbit austin.rabbitmq.exchange.name=austin.point ##################### redis properties ##################### -spring.redis.host=${austin-redis-ip} -spring.redis.port=${austin-redis-port} -spring.redis.password=${austin-redis-password} +spring.redis.host=${austin.redis.ip} +spring.redis.port=${austin.redis.port} +spring.redis.password=${austin.redis.password} ##################### business properties ##################### austin.business.topic.name=austinBusiness austin.business.recall.topic.name=austinRecall austin.business.recall.group.name=recallGroupId austin.business.log.topic.name=austinTraceLog -austin.business.graylog.ip=${austin-grayLog-ip} +austin.business.graylog.ip=${austin.grayLog.ip} # TODO kafka tag filter,if you need, replace tagIdValue ,eg:com.java3y.austin.yyy austin.business.tagId.key=kafka_tag_id @@ -109,7 +110,7 @@ austin.business.tagId.value=com.java3y.austin.3y austin.business.upload.crowd.path=/Users/3y/temp ##################### xxl properties ##################### -xxl.job.admin.addresses=http://${austin-xxl-job-ip}:${austin-xxl-job-port}/xxl-job-admin +xxl.job.admin.addresses=http://${austin.xxl.job.ip}:${austin.xxl.job.port}/xxl-job-admin xxl.job.admin.username=admin xxl.job.admin.password=123456 xxl.job.executor.appname=austin @@ -122,15 +123,14 @@ xxl.job.accessToken= ##################### apollo ##################### app.id=austin -apollo.bootstrap.enabled=${apollo.enabled} +apollo.bootstrap.enabled=${austin.apollo.enabled} apollo.bootstrap.namespaces=boss.austin,dynamic-tp-apollo-dtp.yml ##################### nacos ##################### -austin.nacos.enabled=true austin.nacos.server= -austin.nacos.dataId= -austin.nacos.group= -austin.nacos.namespace= +austin.nacos.dataId=austin +austin.nacos.group=DEFAULT_GROUP +austin.nacos.namespace=9537c674-f3a6-4203-b286-ef0c36bfacb2 ##################### httpUtils properties ##################### ok.http.connect-timeout=30 diff --git a/docker/Dockerfile b/docker/Dockerfile index 6834454..c815681 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -14,4 +14,4 @@ EXPOSE 8080 ENTRYPOINT ["sh","-c","java -jar $JAVA_OPTS austin.jar $PARAMS"] -# docker run -e PARAMS="--austin-database-ip= --austin-database-port=3306 --austin-redis-ip= --austin-mq-pipeline=eventbus " -p 8080:8080 --name austin:1.0 +# docker run -e PARAMS="--austin.database.ip= --austin.database.port=3306 --austin.redis.ip= --austin.mq.pipeline=eventbus " -p 8080:8080 --name austin:1.0