Skip to content

Commit

Permalink
merge master into vip
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhongFuCheng3y committed Aug 3, 2022
2 parents d21c88f + 530001a commit 0790dfd
Show file tree
Hide file tree
Showing 29 changed files with 788 additions and 81 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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`图表

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.java3y.austin.common.constant;

public class CommonConstant {
public final static String PERIOD = ".";
public final static String COMMA = ",";
public final static String COLON = ":";
public final static String SEMICOLON = ";";
public final static String POUND = "#";
public final static String SLASH = "/";
public final static String BACKSLASH = "\\";
public final static String EMPTY_STRING = "";
//
public final static String ONE = "1";
public final static String ZERO = "0";
public final static String MINUS_ONE = "-1";
public final static String YES = "Y";
public final static String NO = "N";
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
@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}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* @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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
@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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* @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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
* 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}"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
* 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}"
)
Expand Down
5 changes: 5 additions & 0 deletions austin-support/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@
<groupId>org.springframework.amqp</groupId>
<artifactId>spring-rabbit</artifactId>
</dependency>
<!--nacos-->
<dependency>
<groupId>com.alibaba.boot</groupId>
<artifactId>nacos-config-spring-boot-starter</artifactId>
</dependency>

</dependencies>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.java3y.austin.support.dao;


import com.java3y.austin.support.domain.ChannelAccount;
import com.java3y.austin.support.domain.MessageTemplate;
import com.java3y.austin.support.domain.SmsRecord;
import org.springframework.data.domain.Pageable;
import org.springframework.data.repository.CrudRepository;

import java.util.List;

/**
* 渠道账号信息 Dao
*
* @author 3y
*/
public interface ChannelAccountDao extends CrudRepository<ChannelAccount, Long> {


/**
* 查询 列表(分页)
*
* @param deleted 0:未删除 1:删除
* @param channelType 渠道值
* @return
*/
List<ChannelAccount> findAllByIsDeletedEqualsAndSendChannelEquals(Integer deleted, Integer channelType);


/**
* 统计未删除的条数
*
* @param deleted
* @return
*/
Long countByIsDeletedEquals(Integer deleted);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package com.java3y.austin.support.domain;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

/**
* @author 3y
* 渠道账号信息
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Entity
public class ChannelAccount {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

/**
* 账号名称
*/
private String name;

/**
* 发送渠道
* 枚举值:com.java3y.austin.common.enums.ChannelType
*/
private Integer sendChannel;

/**
* 账号配置
*/
private String accountConfig;

/**
* 是否删除
* 0:未删除
* 1:已删除
*/
private Integer isDeleted;

/**
* 创建时间 单位 s
*/
private Integer created;

/**
* 更新时间 单位s
*/
private Integer updated;

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
@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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
@Slf4j
@Service
@ConditionalOnProperty(name = "austin-mq-pipeline", havingValue = MessageQueuePipeline.KAFKA)
@ConditionalOnProperty(name = "austin.mq.pipeline", havingValue = MessageQueuePipeline.KAFKA)
public class KafkaSendMqServiceImpl implements SendMqService {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
@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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
@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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ public interface ConfigService {

/**
* 读取配置
* 1、当启动使用了apollo,优先读取apollo
* 2、当没有启动apollo,读取本地 local.properties 配置文件的内容
* 1、当启动使用了apollo或者nacos,优先读取远程配置
* 2、当没有启动远程配置,读取本地 local.properties 配置文件的内容
* @param key
* @param defaultValue
* @return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import cn.hutool.setting.dialect.Props;
import com.ctrip.framework.apollo.Config;
import com.java3y.austin.support.service.ConfigService;
import com.java3y.austin.support.utils.NacosUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

Expand All @@ -30,12 +32,22 @@ public class ConfigServiceImpl implements ConfigService {
private Boolean enableApollo;
@Value("${apollo.bootstrap.namespaces}")
private String namespaces;
/**
* nacos配置
*/
@Value("${austin.nacos.enabled}")
private Boolean enableNacos;
@Autowired
private NacosUtils nacosUtils;


@Override
public String getProperty(String key, String defaultValue) {
if (enableApollo) {
Config config = com.ctrip.framework.apollo.ConfigService.getConfig(namespaces.split(StrUtil.COMMA)[0]);
return config.getProperty(key, defaultValue);
} else if (enableNacos) {
return nacosUtils.getProperty(key, defaultValue);
} else {
return props.getProperty(key, defaultValue);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
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;
Expand All @@ -22,11 +22,8 @@
@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;
Expand Down Expand Up @@ -54,15 +51,13 @@ public void print(AnchorInfo anchorInfo) {
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));
}
}

/**
Expand Down
Loading

0 comments on commit 0790dfd

Please sign in to comment.