1、将apollo变更为弱依赖

2、xxl-job 增加开关
3、邮件安全配置改为读取配置
pull/11/head
3y 3 years ago
parent c217a85295
commit ec2950b0b3

@ -60,7 +60,7 @@ austin项目**核心流程**`austin-api`接收到发送消息请求,直接
## 使用姿势
目前引用的中间件教程的安装姿势均基于`Centos 7.6`(**完全部署所有的服务大概8G内存**)austin项目**强依赖**`MySQL`/`Redis`/`Kafka`/`apollo`**弱依赖**`prometheus`/`graylog`/`flink`/`xxl-job`。如果缺少相关的组件可戳:[安装相关组件教程](INSTALL.md)。
目前引用的中间件教程的安装姿势均基于`Centos 7.6`austin项目**强依赖**`MySQL`/`Redis`/`Kafka`(**大概需要4G内存**)**弱依赖**`prometheus`/`graylog`/`flink`/`xxl-job`/`apollo`(**完全部署所有的服务大概8G+内存**)。如果缺少相关的组件可戳:[安装相关组件教程](INSTALL.md)。
@ -78,15 +78,13 @@ austin项目**核心流程**`austin-api`接收到发送消息请求,直接
**5**、填写`application.properties`中`austin-redis`对应的`ip`/`port`信息
**6**、检查`apollo`的`app.id`/`apollo.bootstrap.namespaces`,检查创建的消息队列topic`austin.business.topic.name`
**6**、检查消息队列topic`austin.business.topic.name`(我的topicName为austinBusiness)
**7**、以上配置信息都在`application.properties`文件中修改。
**7**、以上配置信息都在`application.properties`文件中修改。(`prometheus`/`graylog`/`flink`/`xxl-job`/`apollo`可选)
**8**、由于使用了Apollo且我是在云服务器上安装的我这边会直接跳过`metaserver`服务发现,在`AustinApplication`需要配置对应的apollo地址(注意端口!)
**8**、发送渠道**账号的信息**都配置在**local.properties**,配置的示例参照`com.java3y.austin.support.utils#getAccount`中的注释
**9**、发送渠道**账号的信息**都配置在**apollo**,配置的示例参照`com.java3y.austin.support.utils#getAccount`中的注释
**10**、调用http接口`com.java3y.austin.web.controller#send`给自己发一条短信或者邮件感受
**10**、调用http接口`com.java3y.austin.web.controller#send`给自己发一条邮件或短信感受(**邮件门槛相对较低,建议配置邮件**)
```shell
curl -XPOST "127.0.0.1:8080/send" -H 'Content-Type: application/json' -d '{"code":"send","messageParam":{"extra":null,"receiver":"13719333899"},"messageTemplateId":1}'
@ -110,6 +108,8 @@ curl -XPOST "127.0.0.1:8080/send" -H 'Content-Type: application/json' -d '{"co
**14**、正常使用**系统监控**需要部署`promethus`和`grafana`,根据[部署文档](INSTALL.md)配置`grafana`图表
**15**、正常使用**动态配置中心**需要部署`apollo`,根据[部署文档](INSTALL.md)启动`apollo`,通过docker-compose启动需要在AustinApplication注入对应的ip和port(可看注释)
## 会员服务
收费课程是以**项目**为主代码在Gitee和GitHub上都是开源的项目没有商业版后面也不会有。那么付费跟我自己去拉Git仓库拉代码下来看有什么区别

@ -3,6 +3,7 @@ package com.java3y.austin.cron.xxl.config;
import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -12,6 +13,7 @@ import org.springframework.context.annotation.Configuration;
*/
@Slf4j
@Configuration
@ConditionalOnProperty(name = "xxl-job.enabled",havingValue = "true")
public class XxlJobConfig {
@Value("${xxl.job.admin.addresses}")

@ -1,10 +1,9 @@
package com.java3y.austin.handler.deduplication;
import com.ctrip.framework.apollo.Config;
import com.ctrip.framework.apollo.spring.annotation.ApolloConfig;
import com.java3y.austin.common.constant.AustinConstant;
import com.java3y.austin.common.domain.TaskInfo;
import com.java3y.austin.common.enums.DeduplicationType;
import com.java3y.austin.support.service.ConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -18,10 +17,10 @@ import java.util.List;
@Service
public class DeduplicationRuleService {
public static final String DEDUPLICATION_RULE_KEY = "deduplication";
public static final String DEDUPLICATION_RULE_KEY = "deduplicationRule";
@ApolloConfig("boss.austin")
private Config config;
@Autowired
private ConfigService config;
@Autowired
private DeduplicationHolder deduplicationHolder;

@ -2,12 +2,11 @@ package com.java3y.austin.handler.discard;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.ctrip.framework.apollo.Config;
import com.ctrip.framework.apollo.spring.annotation.ApolloConfig;
import com.java3y.austin.common.constant.AustinConstant;
import com.java3y.austin.common.domain.AnchorInfo;
import com.java3y.austin.common.domain.TaskInfo;
import com.java3y.austin.common.enums.AnchorState;
import com.java3y.austin.support.service.ConfigService;
import com.java3y.austin.support.utils.LogUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -18,10 +17,10 @@ import org.springframework.stereotype.Service;
*/
@Service
public class DiscardMessageService {
private static final String DISCARD_MESSAGE_KEY = "discard";
private static final String DISCARD_MESSAGE_KEY = "discardMsgIds";
@ApolloConfig("boss.austin")
private Config config;
@Autowired
private ConfigService config;
@Autowired
private LogUtils logUtils;

@ -2,8 +2,6 @@ package com.java3y.austin.handler.flowcontrol.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ctrip.framework.apollo.Config;
import com.ctrip.framework.apollo.spring.annotation.ApolloConfig;
import com.google.common.util.concurrent.RateLimiter;
import com.java3y.austin.common.constant.AustinConstant;
import com.java3y.austin.common.domain.TaskInfo;
@ -11,7 +9,9 @@ import com.java3y.austin.common.enums.ChannelType;
import com.java3y.austin.handler.enums.RateLimitStrategy;
import com.java3y.austin.handler.flowcontrol.FlowControlParam;
import com.java3y.austin.handler.flowcontrol.FlowControlService;
import com.java3y.austin.support.service.ConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
@ -22,12 +22,11 @@ import org.springframework.stereotype.Service;
@Slf4j
public class FlowControlServiceImpl implements FlowControlService {
private static final String FLOW_CONTROL_KEY = "flowControl";
private static final String FLOW_CONTROL_KEY = "flowControlRule";
private static final String FLOW_CONTROL_PREFIX = "flow_control_";
@ApolloConfig("boss.austin")
private Config config;
@Autowired
private ConfigService config;
@Override

@ -67,7 +67,7 @@ public class EmailHandler extends BaseHandler implements Handler {
try {
MailSSLSocketFactory sf = new MailSSLSocketFactory();
sf.setTrustAllHosts(true);
account.setAuth(true).setStarttlsEnable(true).setSslEnable(true).setCustomProperty("mail.smtp.ssl.socketFactory", sf);
account.setAuth(account.isAuth()).setStarttlsEnable(account.isStarttlsEnable()).setSslEnable(account.isSslEnable()).setCustomProperty("mail.smtp.ssl.socketFactory", sf);
account.setTimeout(25000).setConnectionTimeout(25000);
} catch (Exception e) {
log.error("EmailHandler#getAccount fail!{}", Throwables.getStackTraceAsString(e));

@ -19,6 +19,7 @@ import com.java3y.austin.handler.script.SmsScriptHolder;
import com.java3y.austin.support.dao.SmsRecordDao;
import com.java3y.austin.support.domain.MessageTemplate;
import com.java3y.austin.support.domain.SmsRecord;
import com.java3y.austin.support.service.ConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@ -45,8 +46,8 @@ public class SmsHandler extends BaseHandler implements Handler {
@Autowired
private SmsScriptHolder smsScriptHolder;
@ApolloConfig("boss.austin")
private Config config;
@Autowired
private ConfigService config;
@Override
@ -116,7 +117,7 @@ public class SmsHandler extends BaseHandler implements Handler {
* ()
* <p>
*
* keymsg_type_sms_config
* keymsgTypeSmsConfig
* value[{"message_type_10":[{"weights":80,"scriptName":"TencentSmsScript"},{"weights":20,"scriptName":"YunPianSmsScript"}]},{"message_type_20":[{"weights":20,"scriptName":"YunPianSmsScript"}]},{"message_type_30":[{"weights":20,"scriptName":"TencentSmsScript"}]},{"message_type_40":[{"weights":20,"scriptName":"TencentSmsScript"}]}]
* TencentSmsScript 80%YunPianSmsScript20%
* YunPianSmsScript
@ -127,7 +128,7 @@ public class SmsHandler extends BaseHandler implements Handler {
*/
private List<MessageTypeSmsConfig> getMessageTypeSmsConfig(Integer msgType) {
String apolloKey = "msg_type_sms_config";
String apolloKey = "msgTypeSmsConfig";
String messagePrefix = "message_type_";
String property = config.getProperty(apolloKey, AustinConstant.APOLLO_DEFAULT_VALUE_JSON_ARRAY);

@ -0,0 +1,21 @@
package com.java3y.austin.support.service;
/**
*
*
* @author 3y
*/
public interface ConfigService {
/**
*
* 1使apolloapollo
* 2apollo local.properties
* @param key
* @param defaultValue
* @return
*/
String getProperty(String key, String defaultValue);
}

@ -0,0 +1,41 @@
package com.java3y.austin.support.service.impl;
import cn.hutool.core.util.StrUtil;
import cn.hutool.setting.dialect.Props;
import com.ctrip.framework.apollo.Config;
import com.java3y.austin.support.service.ConfigService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
/**
* @author 3y
*
*/
@Service
public class ConfigServiceImpl implements ConfigService {
/**
*
*/
private static final String PROPERTIES_PATH = "local.properties";
private Props props = new Props(PROPERTIES_PATH);
/**
* apollo
*/
@Value("${apollo.bootstrap.enabled}")
private Boolean enableApollo;
@Value("${apollo.bootstrap.namespaces}")
private String namespaces;
@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 {
return props.getProperty(key, defaultValue);
}
}
}

@ -6,6 +6,8 @@ import com.alibaba.fastjson.JSONObject;
import com.ctrip.framework.apollo.Config;
import com.ctrip.framework.apollo.spring.annotation.ApolloConfig;
import com.java3y.austin.common.constant.AustinConstant;
import com.java3y.austin.support.service.ConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
@ -14,15 +16,14 @@ import org.springframework.stereotype.Component;
* @author 3y
*/
@Component
public class AccountUtils {
@ApolloConfig("boss.austin")
private Config config;
@Autowired
private ConfigService config;
/**
* (key:smsAccount)[{"sms_10":{"url":"sms.tencentcloudapi.com","region":"ap-guangzhou","secretId":"AKIDhDxxxxxxxx1WljQq","secretKey":"B4hwww39yxxxrrrrgxyi","smsSdkAppId":"1423123125","templateId":"1182097","signName":"Java3y公众号","supplierId":10,"supplierName":"腾讯云"}},{"sms_20":{"url":"https://sms.yunpian.com/v2/sms/tpl_batch_send.json","apikey":"caffff8234234231b5cd7","tpl_id":"523333332","supplierId":20,"supplierName":"云片"}}]
* (key:emailAccount)[{"email_10":{"host":"smtp.qq.com","port":465,"user":"4032222131@qq.com","pass":"","from":"4036333131@qq.com"}}]
* (key:emailAccount)[{"email_10":{"host":"smtp.qq.com","port":465,"user":"23423423@qq.com","pass":"23423432432423423","from":"234@qq.com","starttlsEnable":true,"auth":true,"sslEnable":true}},{"email_20":{"host":"smtp.163.com","port":465,"user":"22222@163.com","pass":"23432423","from":"234324324234@163.com","starttlsEnable":false,"auth":true,"sslEnable":true}}]
* (key:enterpriseWechatAccount)[{"enterprise_wechat_10":{"corpId":"wwf87603333e00069c","corpSecret":"-IFWxS2222QxzPIorNV11144D915DM","agentId":10044442,"token":"rXROB3333Kf6i","aesKey":"MKZtoFxHIM44444M7ieag3r9ZPUsl"}}]
* (key:dingDingRobotAccount) [{"ding_ding_robot_10":{"secret":"SEC9222d4768aded74114faae92229de422222fedf","webhook":"https://oapi.dingtalk.com/robot/send?access_token=8d03b6442222203d87333367328b0c3003d164715d2c6c6e56"}}]
* (key:dingDingWorkNoticeAccount) [{"ding_ding_work_notice_10":{"appKey":"dingh6yyyyyyycrlbx","appSecret":"tQpvmkR863333yyyyyHP3QHyyyymy9Ao1yoL1oQX5NsdfsWHvWKbTu","agentId":"1523123123183622"}}]

@ -10,8 +10,15 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class AustinApplication {
public static void main(String[] args) {
// TODO apollo的ip/port【must】
System.setProperty("apollo.config-service", "http://ip:7000");
/**
* TODO optional
*
* 1apollo
* 2application.properties apollo.enabled true
* 3propertyipport
*/
System.setProperty("apollo.config-service", "http://ip:port");
SpringApplication.run(AustinApplication.class, args);
}
}

@ -8,6 +8,7 @@ import lombok.NoArgsConstructor;
/**
* Id
* @author 3y
*/
@Builder
@Data

@ -17,10 +17,14 @@ austin-redis-ip=
austin-redis-port=
austin-redis-password=
# todo [xxl-job] ip/port【optional】
# 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 [apollo] switch 【optional】
apollo.enabled=false
# todo [grayLog] ip 【optional】
austin-grayLog-ip=127.0.0.1
@ -56,7 +60,7 @@ austin.business.recall.topic.name=austinRecall
austin.business.recall.group.name=recallGroupId
austin.business.log.topic.name=austinLog
austin.business.graylog.ip=${austin-grayLog-ip}
# TODO if windows os ,replace path !
# TODO if windows os and need upload file to send message ,replace path !
austin.business.upload.crowd.path=/Users/3y/temp
##################### xxl properties #####################
@ -73,7 +77,7 @@ xxl.job.accessToken=
##################### apollo #####################
app.id=austin
apollo.bootstrap.enabled=true
apollo.bootstrap.enabled=${apollo.enabled}
apollo.bootstrap.namespaces=boss.austin,dynamic-tp-apollo-dtp.yml
##################### httpUtils properties #####################

@ -1,10 +1,10 @@
discard = []
deduplication = {"deduplication_10":{"num":1,"time":300},"deduplication_20":{"num":5}}
emailAccount =[{"email_10":{"host":"smtp.qq.com","port":465,"user":"23423432@qq.com","pass":"23423432","from":"234234234@qq.com"}}]
discardMsgIds = []
deduplicationRule = {"deduplication_10":{"num":1,"time":300},"deduplication_20":{"num":5}}
emailAccount =[{"email_10":{"host":"smtp.qq.com","port":465,"user":"23423423@qq.com","pass":"23423432432423423","from":"234@qq.com","starttlsEnable":true,"auth":true,"sslEnable":true}},{"email_20":{"host":"smtp.163.com","port":465,"user":"22222@163.com","pass":"23432423","from":"234324324234@163.com","starttlsEnable":false,"auth":true,"sslEnable":true}}]
smsAccount = [{"sms_10":{"url":"sms.tencentcloudapi.com","region":"ap-guangzhou","secretId":"234234","secretKey":"234324324","smsSdkAppId":"2343242","templateId":"234234","signName":"Java3y公众号","supplierId":10,"supplierName":"腾讯云"}},{"sms_20":{"url":"https://sms.yunpian.com/v2/sms/tpl_batch_send.json","apikey":"23423432","tpl_id":"23423432","supplierId":20,"supplierName":"云片"}}]
enterpriseWechatAccount = [{"enterprise_wechat_10":{"corpId":"23423423","corpSecret":"-234324234","agentId":1000002,"token":"234234","aesKey":"23423423"}}]
dingDingRobotAccount = [{"ding_ding_robot_10":{"secret":"234324324324","webhook":"https://oapi.dingtalk.com/robot/send?access_token=8d03b68d081f732343243242343247328b0c3003d164715d2c6c6e56"}}]
dingDingWorkNoticeAccount =[{"ding_ding_work_notice_10":{"appKey":"23423423","appSecret":"tQpvmkR863dYcuKDVfM23432432432423Nlx_fYLLLlpPJWHvWKbTu","agentId":"1523423423242"}}]
flowControl = {"flow_control_40":1}
flowControlRule = {"flow_control_40":1}
geTuiAccount = [{"ge_tui_account_10":{"appId":"23423423","appKey":"234234234","masterSecret":"2342342342342"}}]
msg_type_sms_config = [{"message_type_10":[{"weights":99,"scriptName":"TencentSmsScript"},{"weights":1,"scriptName":"YunPianSmsScript"}]},{"message_type_20":[{"weights":20,"scriptName":"YunPianSmsScript"}]},{"message_type_30":[{"weights":20,"scriptName":"TencentSmsScript"}]},{"message_type_40":[{"weights":20,"scriptName":"TencentSmsScript"}]}]
msgTypeSmsConfig = [{"message_type_10":[{"weights":99,"scriptName":"TencentSmsScript"},{"weights":1,"scriptName":"YunPianSmsScript"}]},{"message_type_20":[{"weights":20,"scriptName":"YunPianSmsScript"}]},{"message_type_30":[{"weights":20,"scriptName":"TencentSmsScript"}]},{"message_type_40":[{"weights":20,"scriptName":"TencentSmsScript"}]}]
Loading…
Cancel
Save