1、渠道账号走数据库,不再走配置

2、优化部分代码逻辑。
pull/26/head
3y 2 years ago
parent 8f31ee92f6
commit 5cf63b7661

@ -124,7 +124,7 @@ curl -XPOST "127.0.0.1:8080/send" -H 'Content-Type: application/json' -d '{"co
5、除了项目还可以问我些学习经验、学习路线、简历编写、面试经验等等问题技术和学习上的知识**知无不言** 5、除了项目还可以问我些学习经验、学习路线、简历编写、面试经验等等问题技术和学习上的知识**知无不言**
详情可以看戳:[我开通了付费渠道](https://mp.weixin.qq.com/s?__biz=MzI4Njg5MDA5NA==&mid=2247505577&idx=1&sn=5114f8f583755899c2946fbea0b22e4b&chksm=ebd497a8dca31ebe8f98344483a00c860863dfc3586e51eed95b25988151427fee8101311f4f&token=319992632&lang=zh_CN#rd) 详情可以看戳:[我开通了付费渠道](https://mp.weixin.qq.com/s?__biz=MzI4Njg5MDA5NA==&mid=2247507166&idx=1&sn=d4437089c2db18b90a6d3ec742380554&chksm=ebd49ddfdca314c94d49a02da2ecb1358ac08d86616b6f1fce34720cc96e81d3006a51e86beb&token=28465847&lang=zh_CN#rd)
## 项目交流 ## 项目交流

@ -2,30 +2,16 @@ package com.java3y.austin.common.constant;
/** /**
* * Austin
* *
* @author 3y * @author 3y
*/ */
public class AustinConstant { public class AustinConstant {
/** /**
* boolean *
*/ */
public final static Integer TRUE = 1; public static final String ORIGIN_VALUE = "http://localhost:3000";
public final static Integer FALSE = 0;
/**
* cron
*/
public final static String CRON_FORMAT = "ss mm HH dd MM ? yyyy-yyyy";
/**
* apollo
*/
public final static String APOLLO_DEFAULT_VALUE_JSON_OBJECT = "{}";
public final static String APOLLO_DEFAULT_VALUE_JSON_ARRAY = "[]";
/** /**
* businessId * businessId
@ -33,6 +19,10 @@ public class AustinConstant {
*/ */
public final static Integer BUSINESS_ID_LENGTH = 16; public final static Integer BUSINESS_ID_LENGTH = 16;
/**
*
*/
public static final Integer BATCH_RECEIVER_SIZE = 100;
/** /**
* *
@ -43,23 +33,5 @@ public class AustinConstant {
public static final String SEND_ALL = "@all"; public static final String SEND_ALL = "@all";
/**
*
*/
public static final String HMAC_SHA256_ENCRYPTION_ALGO = "HmacSHA256";
/**
*
*/
public static final String CHARSET_NAME = "UTF-8";
/**
* HTTP
*/
public static final String REQUEST_METHOD_GET = "GET";
public static final String REQUEST_METHOD_POST = "POST";
} }

@ -1,6 +1,7 @@
package com.java3y.austin.common.constant; package com.java3y.austin.common.constant;
public class CommonConstant { public class CommonConstant {
public final static String PERIOD = "."; public final static String PERIOD = ".";
public final static String COMMA = ","; public final static String COMMA = ",";
public final static String COLON = ":"; public final static String COLON = ":";
@ -9,10 +10,54 @@ public class CommonConstant {
public final static String SLASH = "/"; public final static String SLASH = "/";
public final static String BACKSLASH = "\\"; public final static String BACKSLASH = "\\";
public final static String EMPTY_STRING = ""; public final static String EMPTY_STRING = "";
// public final static String RADICAL = "|";
public final static String QM_STRING = "?";
public final static String EQUAL_STRING = "=";
public final static String AND_STRING = "&";
public final static String ONE = "1"; public final static String ONE = "1";
public final static String ZERO = "0"; public final static String ZERO = "0";
public final static String MINUS_ONE = "-1"; public final static String MINUS_ONE = "-1";
public final static String YES = "Y"; public final static String YES = "Y";
public final static String NO = "N"; public final static String NO = "N";
public final static char QM = '?';
/**
* boolean
*/
public final static Integer TRUE = 1;
public final static Integer FALSE = 0;
/**
*
*/
public static final String HMAC_SHA256_ENCRYPTION_ALGO = "HmacSHA256";
/**
*
*/
public static final String CHARSET_NAME = "UTF-8";
/**
* HTTP
*/
public static final String REQUEST_METHOD_GET = "GET";
public static final String REQUEST_METHOD_POST = "POST";
/**
* JSON
*/
public final static String EMPTY_JSON_OBJECT = "{}";
public final static String EMPTY_VALUE_JSON_ARRAY = "[]";
/**
* cron
*/
public final static String CRON_FORMAT = "ss mm HH dd MM ? yyyy-yyyy";
} }

@ -3,92 +3,19 @@ package com.java3y.austin.common.constant;
/** /**
* *
* <p>
* (apollokey)
* <p>
* 1010
*
* @author 3y * @author 3y
*/ */
public class SendAccountConstant { public class SendAccountConstant {
/**
* 1010
*/
public static final Integer START = 10;
public static final Integer STEP = 10;
/** /**
* *
*/ */
public static final String DING_DING_WORK_NOTICE_ACCOUNT_KEY = "dingDingWorkNoticeAccount";
public static final String DING_DING_WORK_NOTICE_PREFIX = "ding_ding_work_notice_";
public static final String DING_DING_ACCESS_TOKEN_PREFIX = "ding_ding_access_token_"; public static final String DING_DING_ACCESS_TOKEN_PREFIX = "ding_ding_access_token_";
/** /**
* PUSH * PUSH
*/ */
public static final String GE_TUI_ACCOUNT_KEY = "geTuiAccount";
public static final String GE_TUI_ACCOUNT_PREFIX = "ge_tui_account_";
public static final String GE_TUI_ACCESS_TOKEN_PREFIX = "ge_tui_access_token_"; public static final String GE_TUI_ACCESS_TOKEN_PREFIX = "ge_tui_access_token_";
/**
*
*/
public static final String EMAIL_ACCOUNT_KEY = "emailAccount";
public static final String EMAIL_ACCOUNT_PREFIX = "email_";
/**
*
*/
public static final String DING_DING_ROBOT_ACCOUNT_KEY = "dingDingRobotAccount";
public static final String DING_DING_ROBOT_PREFIX = "ding_ding_robot_";
/**
*
*/
public static final String ENTERPRISE_WECHAT_ROBOT_ACCOUNT_KEY = "enterpriseWechatAccountRobot";
public static final String ENTERPRISE_WECHAT_ROBOT_PREFIX = "enterprise_wechat_robot_";
/**
*
*/
public static final String FEI_SHU_ROBOT_ACCOUNT_KEY = "feiShuAccountRobot";
public static final String FEI_SHU_ROBOT_PREFIX = "fei_shu_robot_";
/**
*
*/
public static final String ENTERPRISE_WECHAT_ACCOUNT_KEY = "enterpriseWechatAccount";
public static final String ENTERPRISE_WECHAT_PREFIX = "enterprise_wechat_";
/**
*
*/
public static final String WECHAT_OFFICIAL_ACCOUNT_KEY = "officialAccount";
public static final String WECHAT_OFFICIAL__PREFIX = "official_";
/**
*
*/
public static final String WECHAT_MINI_PROGRAM_ACCOUNT_KEY = "miniProgramAccount";
public static final String WECHAT_MINI_PROGRAM_PREFIX = "mini_program_";
/**
*
*/
public static final String SMS_ACCOUNT_KEY = "smsAccount";
public static final String SMS_PREFIX = "sms_";
/**
* code
*/
public static final Integer YUN_PIAN_SMS_CODE = 20;
} }

@ -0,0 +1,42 @@
package com.java3y.austin.common.dto.account;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author jwq
*
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class AlipayMiniProgramAccount {
/**
*
*/
private String privateKey;
/**
*
*/
private String alipayPublicKey;
/**
* AppID
*/
private String appId;
/**
* Id
*/
private String userTemplateId;
/**
*
*/
private String page;
}

@ -0,0 +1,28 @@
package com.java3y.austin.common.dto.account.sms;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SmsAccount {
/**
* Id
*/
protected Integer supplierId;
/**
*
*/
protected String supplierName;
/**
*
*
* scriptName
*/
protected String scriptName;
}

@ -0,0 +1,35 @@
package com.java3y.austin.common.dto.account.sms;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
*
*
*
* {"url":"sms.tencentcloudapi.com","region":"ap-guangzhou","secretId":"AKIDhDxxxxxxxx1WljQq","secretKey":"B4hwww39yxxxrrrrgxyi","smsSdkAppId":"1423123125","templateId":"1182097","signName":"Java3y公众号","supplierId":10,"supplierName":"腾讯云","scriptName":"TencentSmsScript"}
*
* @author 3y
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class TencentSmsAccount extends SmsAccount {
/**
* api
*/
private String url;
private String region ;
/**
*
*/
private String secretId;
private String secretKey;
private String smsSdkAppId;
private String templateId;
private String signName;
}

@ -0,0 +1,35 @@
package com.java3y.austin.common.dto.account.sms;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
*
*
*
* {"url":"https://sms.yunpian.com/v2/sms/tpl_batch_send.json","apikey":"caffff8234234231b5cd7","tpl_id":"523333332","supplierId":20,"supplierName":"云片","scriptName":"YunPianSmsScript"}
*
* @author 3y
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class YunPianSmsAccount extends SmsAccount {
/**
* apikey
*/
private String apikey;
/**
* tplId
*/
private String tplId;
/**
* api
*/
private String url;
}

@ -0,0 +1,25 @@
package com.java3y.austin.common.dto.model;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Map;
/**
* @author jwq
*
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class AlipayMiniProgramContentModel extends ContentModel{
/**
*
*/
Map<String, String> map;
}

@ -28,6 +28,7 @@ public enum ChannelType {
DING_DING_WORK_NOTICE(90, "dingDingWorkNotice(钉钉工作通知)", DingDingWorkContentModel.class, "ding_ding_work_notice"), DING_DING_WORK_NOTICE(90, "dingDingWorkNotice(钉钉工作通知)", DingDingWorkContentModel.class, "ding_ding_work_notice"),
ENTERPRISE_WE_CHAT_ROBOT(100, "enterpriseWeChat(企业微信机器人)", EnterpriseWeChatRobotContentModel.class, "enterprise_we_chat_robot"), ENTERPRISE_WE_CHAT_ROBOT(100, "enterpriseWeChat(企业微信机器人)", EnterpriseWeChatRobotContentModel.class, "enterprise_we_chat_robot"),
FEI_SHU_ROBOT(110, "feiShuRoot(飞书机器人)", FeiShuRobotContentModel.class, "fei_shu_robot"), FEI_SHU_ROBOT(110, "feiShuRoot(飞书机器人)", FeiShuRobotContentModel.class, "fei_shu_robot"),
ALIPAY_MINI_PROGRAM(120,"alipayMiniProgram(支付宝小程序)",AlipayMiniProgramContentModel.class,"alipay_mini_program"),
; ;
/** /**

@ -8,6 +8,7 @@ import com.dingtalk.api.request.OapiGettokenRequest;
import com.dingtalk.api.response.OapiGettokenResponse; import com.dingtalk.api.response.OapiGettokenResponse;
import com.google.common.base.Throwables; import com.google.common.base.Throwables;
import com.java3y.austin.common.constant.AustinConstant; import com.java3y.austin.common.constant.AustinConstant;
import com.java3y.austin.common.constant.CommonConstant;
import com.java3y.austin.common.constant.SendAccountConstant; import com.java3y.austin.common.constant.SendAccountConstant;
import com.java3y.austin.common.dto.account.DingDingWorkNoticeAccount; import com.java3y.austin.common.dto.account.DingDingWorkNoticeAccount;
import com.java3y.austin.common.enums.ChannelType; import com.java3y.austin.common.enums.ChannelType;
@ -52,7 +53,7 @@ public class RefreshDingDingAccessTokenHandler {
public void execute() { public void execute() {
log.info("refreshAccessTokenJob#execute!"); log.info("refreshAccessTokenJob#execute!");
SupportThreadPoolConfig.getPendingSingleThreadPool().execute(() -> { SupportThreadPoolConfig.getPendingSingleThreadPool().execute(() -> {
List<ChannelAccount> accountList = channelAccountDao.findAllByIsDeletedEqualsAndSendChannelEquals(AustinConstant.FALSE, ChannelType.DING_DING_WORK_NOTICE.getCode()); List<ChannelAccount> accountList = channelAccountDao.findAllByIsDeletedEqualsAndSendChannelEquals(CommonConstant.FALSE, ChannelType.DING_DING_WORK_NOTICE.getCode());
for (ChannelAccount channelAccount : accountList) { for (ChannelAccount channelAccount : accountList) {
DingDingWorkNoticeAccount account = JSON.parseObject(channelAccount.getAccountConfig(), DingDingWorkNoticeAccount.class); DingDingWorkNoticeAccount account = JSON.parseObject(channelAccount.getAccountConfig(), DingDingWorkNoticeAccount.class);
String accessToken = getAccessToken(account); String accessToken = getAccessToken(account);
@ -76,7 +77,7 @@ public class RefreshDingDingAccessTokenHandler {
OapiGettokenRequest req = new OapiGettokenRequest(); OapiGettokenRequest req = new OapiGettokenRequest();
req.setAppkey(account.getAppKey()); req.setAppkey(account.getAppKey());
req.setAppsecret(account.getAppSecret()); req.setAppsecret(account.getAppSecret());
req.setHttpMethod(AustinConstant.REQUEST_METHOD_GET); req.setHttpMethod(CommonConstant.REQUEST_METHOD_GET);
OapiGettokenResponse rsp = client.execute(req); OapiGettokenResponse rsp = client.execute(req);
accessToken = rsp.getAccessToken(); accessToken = rsp.getAccessToken();
} catch (Exception e) { } catch (Exception e) {

@ -8,6 +8,7 @@ import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.google.common.base.Throwables; import com.google.common.base.Throwables;
import com.java3y.austin.common.constant.AustinConstant; import com.java3y.austin.common.constant.AustinConstant;
import com.java3y.austin.common.constant.CommonConstant;
import com.java3y.austin.common.constant.SendAccountConstant; import com.java3y.austin.common.constant.SendAccountConstant;
import com.java3y.austin.common.dto.account.GeTuiAccount; import com.java3y.austin.common.dto.account.GeTuiAccount;
import com.java3y.austin.common.enums.ChannelType; import com.java3y.austin.common.enums.ChannelType;
@ -51,14 +52,12 @@ public class RefreshGeTuiAccessTokenHandler {
public void execute() { public void execute() {
log.info("refreshGeTuiAccessTokenJob#execute!"); log.info("refreshGeTuiAccessTokenJob#execute!");
SupportThreadPoolConfig.getPendingSingleThreadPool().execute(() -> { SupportThreadPoolConfig.getPendingSingleThreadPool().execute(() -> {
List<ChannelAccount> accountList = channelAccountDao.findAllByIsDeletedEqualsAndSendChannelEquals(AustinConstant.FALSE, ChannelType.PUSH.getCode()); List<ChannelAccount> accountList = channelAccountDao.findAllByIsDeletedEqualsAndSendChannelEquals(CommonConstant.FALSE, ChannelType.PUSH.getCode());
for (int index = SendAccountConstant.START; true; index = index + SendAccountConstant.STEP) { for (ChannelAccount channelAccount : accountList) {
for (ChannelAccount channelAccount : accountList) { GeTuiAccount account = JSON.parseObject(channelAccount.getAccountConfig(), GeTuiAccount.class);
GeTuiAccount account = JSON.parseObject(channelAccount.getAccountConfig(), GeTuiAccount.class); String accessToken = getAccessToken(account);
String accessToken = getAccessToken(account); if (StrUtil.isNotBlank(accessToken)) {
if (StrUtil.isNotBlank(accessToken)) { redisTemplate.opsForValue().set(SendAccountConstant.GE_TUI_ACCESS_TOKEN_PREFIX + channelAccount.getId(), accessToken);
redisTemplate.opsForValue().set(SendAccountConstant.GE_TUI_ACCESS_TOKEN_PREFIX + index, accessToken);
}
} }
} }
}); });

@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.map.MapUtil; import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.java3y.austin.common.constant.AustinConstant;
import com.java3y.austin.cron.config.CronAsyncThreadPoolConfig; import com.java3y.austin.cron.config.CronAsyncThreadPoolConfig;
import com.java3y.austin.cron.constants.PendingConstant; import com.java3y.austin.cron.constants.PendingConstant;
import com.java3y.austin.cron.vo.CrowdInfoVo; import com.java3y.austin.cron.vo.CrowdInfoVo;
@ -40,9 +41,9 @@ public class CrowdBatchTaskPending extends AbstractLazyPending<CrowdInfoVo> {
public CrowdBatchTaskPending() { public CrowdBatchTaskPending() {
PendingParam<CrowdInfoVo> pendingParam = new PendingParam<>(); PendingParam<CrowdInfoVo> pendingParam = new PendingParam<>();
pendingParam.setNumThreshold(PendingConstant.NUM_THRESHOLD) pendingParam.setQueue(new LinkedBlockingQueue(PendingConstant.QUEUE_SIZE))
.setQueue(new LinkedBlockingQueue(PendingConstant.QUEUE_SIZE))
.setTimeThreshold(PendingConstant.TIME_THRESHOLD) .setTimeThreshold(PendingConstant.TIME_THRESHOLD)
.setNumThreshold(AustinConstant.BATCH_RECEIVER_SIZE)
.setExecutorService(CronAsyncThreadPoolConfig.getConsumePendingThreadPool()); .setExecutorService(CronAsyncThreadPoolConfig.getConsumePendingThreadPool());
this.pendingParam = pendingParam; this.pendingParam = pendingParam;
} }

@ -3,6 +3,7 @@ package com.java3y.austin.cron.xxl.utils;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.java3y.austin.common.constant.AustinConstant; import com.java3y.austin.common.constant.AustinConstant;
import com.java3y.austin.common.constant.CommonConstant;
import com.java3y.austin.common.enums.RespStatusEnum; import com.java3y.austin.common.enums.RespStatusEnum;
import com.java3y.austin.common.vo.BasicResultVO; import com.java3y.austin.common.vo.BasicResultVO;
import com.java3y.austin.cron.xxl.constants.XxlJobConstant; import com.java3y.austin.cron.xxl.constants.XxlJobConstant;
@ -44,8 +45,8 @@ public class XxlJobUtils {
String scheduleConf = messageTemplate.getExpectPushTime(); String scheduleConf = messageTemplate.getExpectPushTime();
// 如果没有指定cron表达式说明立即执行(给到xxl-job延迟5秒的cron表达式) // 如果没有指定cron表达式说明立即执行(给到xxl-job延迟5秒的cron表达式)
if (messageTemplate.getExpectPushTime().equals(String.valueOf(AustinConstant.FALSE))) { if (messageTemplate.getExpectPushTime().equals(String.valueOf(CommonConstant.FALSE))) {
scheduleConf = DateUtil.format(DateUtil.offsetSecond(new Date(), XxlJobConstant.DELAY_TIME), AustinConstant.CRON_FORMAT); scheduleConf = DateUtil.format(DateUtil.offsetSecond(new Date(), XxlJobConstant.DELAY_TIME), CommonConstant.CRON_FORMAT);
} }
XxlJobInfo xxlJobInfo = XxlJobInfo.builder() XxlJobInfo xxlJobInfo = XxlJobInfo.builder()
@ -61,7 +62,7 @@ public class XxlJobUtils {
.executorTimeout(XxlJobConstant.TIME_OUT) .executorTimeout(XxlJobConstant.TIME_OUT)
.executorFailRetryCount(XxlJobConstant.RETRY_COUNT) .executorFailRetryCount(XxlJobConstant.RETRY_COUNT)
.glueType(GlueTypeEnum.BEAN.name()) .glueType(GlueTypeEnum.BEAN.name())
.triggerStatus(AustinConstant.FALSE) .triggerStatus(CommonConstant.FALSE)
.glueRemark(StrUtil.EMPTY) .glueRemark(StrUtil.EMPTY)
.glueSource(StrUtil.EMPTY) .glueSource(StrUtil.EMPTY)
.alarmEmail(StrUtil.EMPTY) .alarmEmail(StrUtil.EMPTY)
@ -80,7 +81,7 @@ public class XxlJobUtils {
private Integer queryJobGroupId() { private Integer queryJobGroupId() {
BasicResultVO basicResultVO = cronTaskService.getGroupId(appName, jobHandlerName); BasicResultVO basicResultVO = cronTaskService.getGroupId(appName, jobHandlerName);
if (basicResultVO.getData() == null) { if (basicResultVO.getData() == null) {
XxlJobGroup xxlJobGroup = XxlJobGroup.builder().appname(appName).title(jobHandlerName).addressType(AustinConstant.FALSE).build(); XxlJobGroup xxlJobGroup = XxlJobGroup.builder().appname(appName).title(jobHandlerName).addressType(CommonConstant.FALSE).build();
if (RespStatusEnum.SUCCESS.getCode().equals(cronTaskService.createGroup(xxlJobGroup).getStatus())) { if (RespStatusEnum.SUCCESS.getCode().equals(cronTaskService.createGroup(xxlJobGroup).getStatus())) {
return (int) cronTaskService.getGroupId(appName, jobHandlerName).getData(); return (int) cronTaskService.getGroupId(appName, jobHandlerName).getData();
} }

@ -57,6 +57,11 @@
<groupId>com.github.binarywang</groupId> <groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-cp</artifactId> <artifactId>weixin-java-cp</artifactId>
</dependency> </dependency>
<!--支付宝SDK-->
<dependency>
<groupId>com.alipay.sdk</groupId>
<artifactId>alipay-sdk-java</artifactId>
</dependency>
</dependencies> </dependencies>
</project> </project>

@ -0,0 +1,18 @@
package com.java3y.austin.handler.alipay;
import com.alipay.api.AlipayApiException;
import com.java3y.austin.handler.domain.alipay.AlipayMiniProgramParam;
/**
* @author jwq
*
*/
public interface AlipayMiniProgramAccountService {
/**
*
*
* @param miniProgramParam
* @throws AlipayApiException alipay
*/
void send(AlipayMiniProgramParam miniProgramParam) throws AlipayApiException;
}

@ -0,0 +1,86 @@
package com.java3y.austin.handler.alipay.impl;
import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
import com.alipay.api.AlipayConfig;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.domain.AlipayOpenAppMiniTemplatemessageSendModel;
import com.alipay.api.request.AlipayOpenAppMiniTemplatemessageSendRequest;
import com.java3y.austin.common.constant.SendAccountConstant;
import com.java3y.austin.common.dto.account.AlipayMiniProgramAccount;
import com.java3y.austin.handler.alipay.AlipayMiniProgramAccountService;
import com.java3y.austin.handler.domain.alipay.AlipayMiniProgramParam;
import com.java3y.austin.support.utils.AccountUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
/**
* @author jwq
*
*/
@Service
@Slf4j
public class AlipayMiniProgramAccountServiceImpl implements AlipayMiniProgramAccountService {
@Autowired
private AccountUtils accountUtils;
/**
*
*
* @param miniProgramParam
* @throws AlipayApiException alipay
*/
@Override
public void send(AlipayMiniProgramParam miniProgramParam) throws AlipayApiException {
AlipayMiniProgramAccount miniProgramAccount = accountUtils.getAccountById(miniProgramParam.getSendAccount(), AlipayMiniProgramAccount.class);
AlipayClient client = initService(miniProgramAccount);
List<AlipayOpenAppMiniTemplatemessageSendRequest> request = assembleReq(miniProgramParam, miniProgramAccount);
for(AlipayOpenAppMiniTemplatemessageSendRequest req : request){
client.execute(req);
}
}
/**
*
*/
private List<AlipayOpenAppMiniTemplatemessageSendRequest> assembleReq(AlipayMiniProgramParam alipayMiniProgramParam, AlipayMiniProgramAccount alipayMiniProgramAccount){
Set<String> receiver = alipayMiniProgramParam.getToUserId();
List<AlipayOpenAppMiniTemplatemessageSendRequest> requestList = new ArrayList<>(receiver.size());
for(String toUserId : receiver){
AlipayOpenAppMiniTemplatemessageSendRequest request = new AlipayOpenAppMiniTemplatemessageSendRequest();
AlipayOpenAppMiniTemplatemessageSendModel model = new AlipayOpenAppMiniTemplatemessageSendModel();
model.setToUserId(toUserId);
model.setUserTemplateId(alipayMiniProgramAccount.getUserTemplateId());
model.setPage(alipayMiniProgramAccount.getPage());
model.setData(alipayMiniProgramParam.getData().toString());
request.setBizModel(model);
requestList.add(request);
}
return requestList;
}
/**
*
*/
private AlipayClient initService(AlipayMiniProgramAccount alipayMiniProgramAccount) throws AlipayApiException {
AlipayConfig alipayConfig = new AlipayConfig();
alipayConfig.setServerUrl("https://openapi.alipaydev.com/gateway.do");
alipayConfig.setAppId(alipayMiniProgramAccount.getAppId());
alipayConfig.setPrivateKey(alipayMiniProgramAccount.getPrivateKey());
alipayConfig.setFormat("json");
alipayConfig.setAlipayPublicKey(alipayMiniProgramAccount.getAlipayPublicKey());
alipayConfig.setCharset("utf-8");
alipayConfig.setSignType("RSA2");
return new DefaultAlipayClient(alipayConfig);
}
}

@ -1,6 +1,7 @@
package com.java3y.austin.handler.deduplication; package com.java3y.austin.handler.deduplication;
import com.java3y.austin.common.constant.AustinConstant; import com.java3y.austin.common.constant.AustinConstant;
import com.java3y.austin.common.constant.CommonConstant;
import com.java3y.austin.common.domain.TaskInfo; import com.java3y.austin.common.domain.TaskInfo;
import com.java3y.austin.common.enums.DeduplicationType; import com.java3y.austin.common.enums.DeduplicationType;
import com.java3y.austin.support.service.ConfigService; import com.java3y.austin.support.service.ConfigService;
@ -27,7 +28,7 @@ public class DeduplicationRuleService {
public void duplication(TaskInfo taskInfo) { public void duplication(TaskInfo taskInfo) {
// 配置样例:{"deduplication_10":{"num":1,"time":300},"deduplication_20":{"num":5}} // 配置样例:{"deduplication_10":{"num":1,"time":300},"deduplication_20":{"num":5}}
String deduplicationConfig = config.getProperty(DEDUPLICATION_RULE_KEY, AustinConstant.APOLLO_DEFAULT_VALUE_JSON_OBJECT); String deduplicationConfig = config.getProperty(DEDUPLICATION_RULE_KEY, CommonConstant.EMPTY_JSON_OBJECT);
// 去重 // 去重
List<Integer> deduplicationList = DeduplicationType.getDeduplicationList(); List<Integer> deduplicationList = DeduplicationType.getDeduplicationList();

@ -2,6 +2,7 @@ package com.java3y.austin.handler.deduplication.limit;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import com.java3y.austin.common.constant.AustinConstant; import com.java3y.austin.common.constant.AustinConstant;
import com.java3y.austin.common.constant.CommonConstant;
import com.java3y.austin.common.domain.TaskInfo; import com.java3y.austin.common.domain.TaskInfo;
import com.java3y.austin.handler.deduplication.DeduplicationParam; import com.java3y.austin.handler.deduplication.DeduplicationParam;
import com.java3y.austin.handler.deduplication.service.AbstractDeduplicationService; import com.java3y.austin.handler.deduplication.service.AbstractDeduplicationService;
@ -66,7 +67,7 @@ public class SimpleLimitService extends AbstractLimitService {
if (inRedisValue.get(key) != null) { if (inRedisValue.get(key) != null) {
keyValues.put(key, String.valueOf(Integer.valueOf(inRedisValue.get(key)) + 1)); keyValues.put(key, String.valueOf(Integer.valueOf(inRedisValue.get(key)) + 1));
} else { } else {
keyValues.put(key, String.valueOf(AustinConstant.TRUE)); keyValues.put(key, String.valueOf(CommonConstant.TRUE));
} }
} }
if (CollUtil.isNotEmpty(keyValues)) { if (CollUtil.isNotEmpty(keyValues)) {

@ -3,6 +3,7 @@ package com.java3y.austin.handler.discard;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.java3y.austin.common.constant.AustinConstant; import com.java3y.austin.common.constant.AustinConstant;
import com.java3y.austin.common.constant.CommonConstant;
import com.java3y.austin.common.domain.AnchorInfo; import com.java3y.austin.common.domain.AnchorInfo;
import com.java3y.austin.common.domain.TaskInfo; import com.java3y.austin.common.domain.TaskInfo;
import com.java3y.austin.common.enums.AnchorState; import com.java3y.austin.common.enums.AnchorState;
@ -33,8 +34,7 @@ public class DiscardMessageService {
*/ */
public boolean isDiscard(TaskInfo taskInfo) { public boolean isDiscard(TaskInfo taskInfo) {
// 配置示例: ["1","2"] // 配置示例: ["1","2"]
JSONArray array = JSON.parseArray(config.getProperty(DISCARD_MESSAGE_KEY, JSONArray array = JSON.parseArray(config.getProperty(DISCARD_MESSAGE_KEY, CommonConstant.EMPTY_VALUE_JSON_ARRAY));
AustinConstant.APOLLO_DEFAULT_VALUE_JSON_ARRAY));
if (array.contains(String.valueOf(taskInfo.getMessageTemplateId()))) { if (array.contains(String.valueOf(taskInfo.getMessageTemplateId()))) {
logUtils.print(AnchorInfo.builder().businessId(taskInfo.getBusinessId()).ids(taskInfo.getReceiver()).state(AnchorState.DISCARD.getCode()).build()); logUtils.print(AnchorInfo.builder().businessId(taskInfo.getBusinessId()).ids(taskInfo.getReceiver()).state(AnchorState.DISCARD.getCode()).build());

@ -0,0 +1,43 @@
package com.java3y.austin.handler.domain.alipay;
import lombok.Builder;
import lombok.Data;
import java.util.Map;
import java.util.Set;
/**
* @author jwq
*
*/
@Data
@Builder
public class AlipayMiniProgramParam {
/**
* Id
*/
private Long messageTemplateId;
/**
*
*/
private Integer sendAccount;
/**
* UserId
*/
private Set<String> toUserId;
/**
* { "key1": { "value": any }, "key2": { "value": any } }
*/
private Map<String, String> data;
// /**
// * 支付消息模板:需传入用户发生的交易行为的支付宝交易号 trade_no
// * 表单提交模板:需传入用户在小程序触发表单提交事件获得的表单号;
// * 刷脸消息模板需传入在IOT刷脸后得到的ftoken等用于信息发送的校验。
// * 说明:订阅消息模板无需传入本参数。
// */
// private String formId;
}

@ -25,9 +25,9 @@ public class SmsParam {
private Set<String> phones; private Set<String> phones;
/** /**
* Id *
*/ */
private Integer sendAccountId; private String scriptName;
/** /**

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.google.common.util.concurrent.RateLimiter; import com.google.common.util.concurrent.RateLimiter;
import com.java3y.austin.common.constant.AustinConstant; import com.java3y.austin.common.constant.AustinConstant;
import com.java3y.austin.common.constant.CommonConstant;
import com.java3y.austin.common.domain.TaskInfo; import com.java3y.austin.common.domain.TaskInfo;
import com.java3y.austin.common.enums.ChannelType; import com.java3y.austin.common.enums.ChannelType;
import com.java3y.austin.handler.enums.RateLimitStrategy; import com.java3y.austin.handler.enums.RateLimitStrategy;
@ -76,7 +77,7 @@ public class FlowControlFactory implements ApplicationContextAware {
* @param channelCode * @param channelCode
*/ */
private Double getRateLimitConfig(Integer channelCode) { private Double getRateLimitConfig(Integer channelCode) {
String flowControlConfig = config.getProperty(FLOW_CONTROL_KEY, AustinConstant.APOLLO_DEFAULT_VALUE_JSON_OBJECT); String flowControlConfig = config.getProperty(FLOW_CONTROL_KEY, CommonConstant.EMPTY_JSON_OBJECT);
JSONObject jsonObject = JSON.parseObject(flowControlConfig); JSONObject jsonObject = JSON.parseObject(flowControlConfig);
if (jsonObject.getDouble(FLOW_CONTROL_PREFIX + channelCode) == null) { if (jsonObject.getDouble(FLOW_CONTROL_PREFIX + channelCode) == null) {
return null; return null;

@ -0,0 +1,67 @@
package com.java3y.austin.handler.handler.impl;
import com.alibaba.fastjson.JSON;
import com.google.common.base.Throwables;
import com.java3y.austin.common.domain.TaskInfo;
import com.java3y.austin.common.dto.model.AlipayMiniProgramContentModel;
import com.java3y.austin.common.enums.ChannelType;
import com.java3y.austin.handler.alipay.AlipayMiniProgramAccountService;
import com.java3y.austin.handler.domain.alipay.AlipayMiniProgramParam;
import com.java3y.austin.handler.handler.BaseHandler;
import com.java3y.austin.handler.handler.Handler;
import com.java3y.austin.support.domain.MessageTemplate;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* @author jwq
*
*/
@Component
@Slf4j
public class AlipayMiniProgramAccountHandler extends BaseHandler implements Handler {
@Autowired
private AlipayMiniProgramAccountService alipayMiniProgramAccountService;
public AlipayMiniProgramAccountHandler() {
channelCode = ChannelType.ALIPAY_MINI_PROGRAM.getCode();
}
@Override
public boolean handler(TaskInfo taskInfo) {
AlipayMiniProgramParam miniProgramParam = buildMiniProgramParam(taskInfo);
try {
alipayMiniProgramAccountService.send(miniProgramParam);
}catch (Exception e) {
log.error("AlipayMiniProgramAccountHandler#handler fail:{},params:{}",
Throwables.getStackTraceAsString(e), JSON.toJSONString(taskInfo));
return false;
}
return true;
}
/**
* taskInfo
*
* @param taskInfo
* @return AlipayMiniProgramParam
*/
private AlipayMiniProgramParam buildMiniProgramParam(TaskInfo taskInfo){
AlipayMiniProgramParam param = AlipayMiniProgramParam.builder()
.toUserId(taskInfo.getReceiver())
.messageTemplateId(taskInfo.getMessageTemplateId())
.sendAccount(taskInfo.getSendAccount())
.build();
AlipayMiniProgramContentModel contentModel = (AlipayMiniProgramContentModel) taskInfo.getContentModel();
param.setData(contentModel.getMap());
return param;
}
@Override
public void recall(MessageTemplate messageTemplate) {
}
}

@ -6,6 +6,7 @@ import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.google.common.base.Throwables; import com.google.common.base.Throwables;
import com.java3y.austin.common.constant.AustinConstant; import com.java3y.austin.common.constant.AustinConstant;
import com.java3y.austin.common.constant.CommonConstant;
import com.java3y.austin.common.constant.SendAccountConstant; import com.java3y.austin.common.constant.SendAccountConstant;
import com.java3y.austin.common.domain.TaskInfo; import com.java3y.austin.common.domain.TaskInfo;
import com.java3y.austin.common.dto.account.DingDingRobotAccount; import com.java3y.austin.common.dto.account.DingDingRobotAccount;
@ -48,7 +49,7 @@ public class DingDingRobotHandler extends BaseHandler implements Handler {
@Override @Override
public boolean handler(TaskInfo taskInfo) { public boolean handler(TaskInfo taskInfo) {
try { try {
DingDingRobotAccount account = accountUtils.getAccount(taskInfo.getSendAccount(), SendAccountConstant.DING_DING_ROBOT_ACCOUNT_KEY, SendAccountConstant.DING_DING_ROBOT_PREFIX, DingDingRobotAccount.class); DingDingRobotAccount account = accountUtils.getAccountById(taskInfo.getSendAccount(), DingDingRobotAccount.class);
DingDingRobotParam dingDingRobotParam = assembleParam(taskInfo); DingDingRobotParam dingDingRobotParam = assembleParam(taskInfo);
String httpResult = HttpUtil.post(assembleParamUrl(account), JSON.toJSONString(dingDingRobotParam)); String httpResult = HttpUtil.post(assembleParamUrl(account), JSON.toJSONString(dingDingRobotParam));
DingDingRobotResult dingDingRobotResult = JSON.parseObject(httpResult, DingDingRobotResult.class); DingDingRobotResult dingDingRobotResult = JSON.parseObject(httpResult, DingDingRobotResult.class);
@ -126,10 +127,10 @@ public class DingDingRobotHandler extends BaseHandler implements Handler {
String sign = ""; String sign = "";
try { try {
String stringToSign = currentTimeMillis + String.valueOf(StrUtil.C_LF) + secret; String stringToSign = currentTimeMillis + String.valueOf(StrUtil.C_LF) + secret;
Mac mac = Mac.getInstance(AustinConstant.HMAC_SHA256_ENCRYPTION_ALGO); Mac mac = Mac.getInstance(CommonConstant.HMAC_SHA256_ENCRYPTION_ALGO);
mac.init(new SecretKeySpec(secret.getBytes(AustinConstant.CHARSET_NAME), AustinConstant.HMAC_SHA256_ENCRYPTION_ALGO)); mac.init(new SecretKeySpec(secret.getBytes(CommonConstant.CHARSET_NAME), CommonConstant.HMAC_SHA256_ENCRYPTION_ALGO));
byte[] signData = mac.doFinal(stringToSign.getBytes(AustinConstant.CHARSET_NAME)); byte[] signData = mac.doFinal(stringToSign.getBytes(CommonConstant.CHARSET_NAME));
sign = URLEncoder.encode(new String(Base64.encodeBase64(signData)), AustinConstant.CHARSET_NAME); sign = URLEncoder.encode(new String(Base64.encodeBase64(signData)), CommonConstant.CHARSET_NAME);
} catch (Exception e) { } catch (Exception e) {
log.error("DingDingHandler#assembleSign fail!:{}", Throwables.getStackTraceAsString(e)); log.error("DingDingHandler#assembleSign fail!:{}", Throwables.getStackTraceAsString(e));
} }

@ -65,7 +65,7 @@ public class DingDingWorkNoticeHandler extends BaseHandler implements Handler {
@Override @Override
public boolean handler(TaskInfo taskInfo) { public boolean handler(TaskInfo taskInfo) {
try { try {
DingDingWorkNoticeAccount account = accountUtils.getAccount(taskInfo.getSendAccount(), SendAccountConstant.DING_DING_WORK_NOTICE_ACCOUNT_KEY, SendAccountConstant.DING_DING_WORK_NOTICE_PREFIX, DingDingWorkNoticeAccount.class); DingDingWorkNoticeAccount account = accountUtils.getAccountById(taskInfo.getSendAccount(), DingDingWorkNoticeAccount.class);
OapiMessageCorpconversationAsyncsendV2Request request = assembleParam(account, taskInfo); OapiMessageCorpconversationAsyncsendV2Request request = assembleParam(account, taskInfo);
String accessToken = redisTemplate.opsForValue().get(SendAccountConstant.DING_DING_ACCESS_TOKEN_PREFIX + taskInfo.getSendAccount()); String accessToken = redisTemplate.opsForValue().get(SendAccountConstant.DING_DING_ACCESS_TOKEN_PREFIX + taskInfo.getSendAccount());
OapiMessageCorpconversationAsyncsendV2Response response = new DefaultDingTalkClient(SEND_URL).execute(request, accessToken); OapiMessageCorpconversationAsyncsendV2Response response = new DefaultDingTalkClient(SEND_URL).execute(request, accessToken);
@ -179,7 +179,7 @@ public class DingDingWorkNoticeHandler extends BaseHandler implements Handler {
public void recall(MessageTemplate messageTemplate) { public void recall(MessageTemplate messageTemplate) {
SupportThreadPoolConfig.getPendingSingleThreadPool().execute(() -> { SupportThreadPoolConfig.getPendingSingleThreadPool().execute(() -> {
try { try {
DingDingWorkNoticeAccount account = accountUtils.getAccount(messageTemplate.getSendAccount(), SendAccountConstant.DING_DING_WORK_NOTICE_ACCOUNT_KEY, SendAccountConstant.DING_DING_WORK_NOTICE_PREFIX, DingDingWorkNoticeAccount.class); DingDingWorkNoticeAccount account = accountUtils.getAccountById(messageTemplate.getSendAccount(), DingDingWorkNoticeAccount.class);
String accessToken = redisTemplate.opsForValue().get(SendAccountConstant.DING_DING_ACCESS_TOKEN_PREFIX + messageTemplate.getSendAccount()); String accessToken = redisTemplate.opsForValue().get(SendAccountConstant.DING_DING_ACCESS_TOKEN_PREFIX + messageTemplate.getSendAccount());
while (redisTemplate.opsForList().size(DING_DING_RECALL_KEY_PREFIX + messageTemplate.getId()) > 0) { while (redisTemplate.opsForList().size(DING_DING_RECALL_KEY_PREFIX + messageTemplate.getId()) > 0) {
String taskId = redisTemplate.opsForList().leftPop(DING_DING_RECALL_KEY_PREFIX + messageTemplate.getId()); String taskId = redisTemplate.opsForList().leftPop(DING_DING_RECALL_KEY_PREFIX + messageTemplate.getId());

@ -63,7 +63,7 @@ public class EmailHandler extends BaseHandler implements Handler {
* @return * @return
*/ */
private MailAccount getAccountConfig(Integer sendAccount) { private MailAccount getAccountConfig(Integer sendAccount) {
MailAccount account = accountUtils.getAccount(sendAccount, SendAccountConstant.EMAIL_ACCOUNT_KEY, SendAccountConstant.EMAIL_ACCOUNT_PREFIX, MailAccount.class); MailAccount account = accountUtils.getAccountById(sendAccount, MailAccount.class);
try { try {
MailSSLSocketFactory sf = new MailSSLSocketFactory(); MailSSLSocketFactory sf = new MailSSLSocketFactory();
sf.setTrustAllHosts(true); sf.setTrustAllHosts(true);

@ -1,9 +1,11 @@
package com.java3y.austin.handler.handler.impl; package com.java3y.austin.handler.handler.impl;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.google.common.base.Throwables; import com.google.common.base.Throwables;
import com.java3y.austin.common.constant.AustinConstant; import com.java3y.austin.common.constant.AustinConstant;
import com.java3y.austin.common.constant.CommonConstant;
import com.java3y.austin.common.constant.SendAccountConstant; import com.java3y.austin.common.constant.SendAccountConstant;
import com.java3y.austin.common.domain.TaskInfo; import com.java3y.austin.common.domain.TaskInfo;
import com.java3y.austin.common.dto.model.EnterpriseWeChatContentModel; import com.java3y.austin.common.dto.model.EnterpriseWeChatContentModel;
@ -38,11 +40,6 @@ import java.util.Map;
@Slf4j @Slf4j
public class EnterpriseWeChatHandler extends BaseHandler implements Handler { public class EnterpriseWeChatHandler extends BaseHandler implements Handler {
/**
* userId
*/
private static final String DELIMITER = "|";
@Autowired @Autowired
private AccountUtils accountUtils; private AccountUtils accountUtils;
@ -53,7 +50,7 @@ public class EnterpriseWeChatHandler extends BaseHandler implements Handler {
@Override @Override
public boolean handler(TaskInfo taskInfo) { public boolean handler(TaskInfo taskInfo) {
try { try {
WxCpDefaultConfigImpl accountConfig = accountUtils.getAccount(taskInfo.getSendAccount(), SendAccountConstant.ENTERPRISE_WECHAT_ACCOUNT_KEY, SendAccountConstant.ENTERPRISE_WECHAT_PREFIX, WxCpDefaultConfigImpl.class); WxCpDefaultConfigImpl accountConfig = accountUtils.getAccountById(taskInfo.getSendAccount(), WxCpDefaultConfigImpl.class);
WxCpMessageServiceImpl messageService = new WxCpMessageServiceImpl(initService(accountConfig)); WxCpMessageServiceImpl messageService = new WxCpMessageServiceImpl(initService(accountConfig));
WxCpMessageSendResult result = messageService.send(buildWxCpMessage(taskInfo, accountConfig.getAgentId())); WxCpMessageSendResult result = messageService.send(buildWxCpMessage(taskInfo, accountConfig.getAgentId()));
if (Integer.valueOf(WxMpErrorMsgEnum.CODE_0.getCode()).equals(result.getErrCode())) { if (Integer.valueOf(WxMpErrorMsgEnum.CODE_0.getCode()).equals(result.getErrCode())) {
@ -93,7 +90,7 @@ public class EnterpriseWeChatHandler extends BaseHandler implements Handler {
if (AustinConstant.SEND_ALL.equals(CollUtil.getFirst(taskInfo.getReceiver()))) { if (AustinConstant.SEND_ALL.equals(CollUtil.getFirst(taskInfo.getReceiver()))) {
userId = CollUtil.getFirst(taskInfo.getReceiver()); userId = CollUtil.getFirst(taskInfo.getReceiver());
} else { } else {
userId = StringUtils.join(taskInfo.getReceiver(), DELIMITER); userId = StringUtils.join(taskInfo.getReceiver(), CommonConstant.RADICAL);
} }
EnterpriseWeChatContentModel contentModel = (EnterpriseWeChatContentModel) taskInfo.getContentModel(); EnterpriseWeChatContentModel contentModel = (EnterpriseWeChatContentModel) taskInfo.getContentModel();

@ -51,7 +51,7 @@ public class EnterpriseWeChatRobotHandler extends BaseHandler implements Handler
@Override @Override
public boolean handler(TaskInfo taskInfo) { public boolean handler(TaskInfo taskInfo) {
try { try {
EnterpriseWeChatRobotAccount account = accountUtils.getAccount(taskInfo.getSendAccount(), SendAccountConstant.ENTERPRISE_WECHAT_ROBOT_ACCOUNT_KEY, SendAccountConstant.ENTERPRISE_WECHAT_ROBOT_PREFIX, EnterpriseWeChatRobotAccount.class); EnterpriseWeChatRobotAccount account = accountUtils.getAccountById(taskInfo.getSendAccount(), EnterpriseWeChatRobotAccount.class);
EnterpriseWeChatRobotParam enterpriseWeChatRobotParam = assembleParam(taskInfo); EnterpriseWeChatRobotParam enterpriseWeChatRobotParam = assembleParam(taskInfo);
String result = HttpRequest.post(account.getWebhook()).header(Header.CONTENT_TYPE.getValue(), ContentType.JSON.getValue()) String result = HttpRequest.post(account.getWebhook()).header(Header.CONTENT_TYPE.getValue(), ContentType.JSON.getValue())
.body(JSON.toJSONString(enterpriseWeChatRobotParam)) .body(JSON.toJSONString(enterpriseWeChatRobotParam))

@ -50,7 +50,7 @@ public class FeiShuRobotHandler extends BaseHandler implements Handler {
@Override @Override
public boolean handler(TaskInfo taskInfo) { public boolean handler(TaskInfo taskInfo) {
try { try {
FeiShuRobotAccount account = accountUtils.getAccount(taskInfo.getSendAccount(), SendAccountConstant.FEI_SHU_ROBOT_ACCOUNT_KEY, SendAccountConstant.FEI_SHU_ROBOT_PREFIX, FeiShuRobotAccount.class); FeiShuRobotAccount account = accountUtils.getAccountById(taskInfo.getSendAccount(), FeiShuRobotAccount.class);
FeiShuRobotParam feiShuRobotParam = assembleParam(taskInfo); FeiShuRobotParam feiShuRobotParam = assembleParam(taskInfo);
String result = HttpRequest.post(account.getWebhook()) String result = HttpRequest.post(account.getWebhook())
.header(Header.CONTENT_TYPE.getValue(), ContentType.JSON.getValue()) .header(Header.CONTENT_TYPE.getValue(), ContentType.JSON.getValue())

@ -58,7 +58,7 @@ public class PushHandler extends BaseHandler implements Handler {
public boolean handler(TaskInfo taskInfo) { public boolean handler(TaskInfo taskInfo) {
try { try {
GeTuiAccount account = accountUtils.getAccount(taskInfo.getSendAccount(), SendAccountConstant.GE_TUI_ACCOUNT_KEY, SendAccountConstant.GE_TUI_ACCOUNT_PREFIX, GeTuiAccount.class); GeTuiAccount account = accountUtils.getAccountById(taskInfo.getSendAccount(),GeTuiAccount.class);
String token = redisTemplate.opsForValue().get(SendAccountConstant.GE_TUI_ACCESS_TOKEN_PREFIX + taskInfo.getSendAccount()); String token = redisTemplate.opsForValue().get(SendAccountConstant.GE_TUI_ACCESS_TOKEN_PREFIX + taskInfo.getSendAccount());
PushParam pushParam = PushParam.builder().token(token).appId(account.getAppId()).taskInfo(taskInfo).build(); PushParam pushParam = PushParam.builder().token(token).appId(account.getAppId()).taskInfo(taskInfo).build();

@ -4,10 +4,9 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.ctrip.framework.apollo.Config;
import com.ctrip.framework.apollo.spring.annotation.ApolloConfig;
import com.google.common.base.Throwables; import com.google.common.base.Throwables;
import com.java3y.austin.common.constant.AustinConstant; import com.java3y.austin.common.constant.AustinConstant;
import com.java3y.austin.common.constant.CommonConstant;
import com.java3y.austin.common.domain.TaskInfo; import com.java3y.austin.common.domain.TaskInfo;
import com.java3y.austin.common.dto.model.SmsContentModel; import com.java3y.austin.common.dto.model.SmsContentModel;
import com.java3y.austin.common.enums.ChannelType; import com.java3y.austin.common.enums.ChannelType;
@ -15,7 +14,7 @@ import com.java3y.austin.handler.domain.sms.MessageTypeSmsConfig;
import com.java3y.austin.handler.domain.sms.SmsParam; import com.java3y.austin.handler.domain.sms.SmsParam;
import com.java3y.austin.handler.handler.BaseHandler; import com.java3y.austin.handler.handler.BaseHandler;
import com.java3y.austin.handler.handler.Handler; import com.java3y.austin.handler.handler.Handler;
import com.java3y.austin.handler.script.SmsScriptHolder; import com.java3y.austin.handler.script.SmsScript;
import com.java3y.austin.support.dao.SmsRecordDao; import com.java3y.austin.support.dao.SmsRecordDao;
import com.java3y.austin.support.domain.MessageTemplate; import com.java3y.austin.support.domain.MessageTemplate;
import com.java3y.austin.support.domain.SmsRecord; import com.java3y.austin.support.domain.SmsRecord;
@ -25,6 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Random; import java.util.Random;
/** /**
@ -44,11 +44,13 @@ public class SmsHandler extends BaseHandler implements Handler {
private SmsRecordDao smsRecordDao; private SmsRecordDao smsRecordDao;
@Autowired @Autowired
private SmsScriptHolder smsScriptHolder; private ConfigService config;
@Autowired @Autowired
private ConfigService config; private Map<String, SmsScript> smsScripts;
private static final String FLOW_KEY = "msgTypeSmsConfig";
private static final String FLOW_KEY_PREFIX = "message_type_";
@Override @Override
public boolean handler(TaskInfo taskInfo) { public boolean handler(TaskInfo taskInfo) {
@ -56,9 +58,7 @@ public class SmsHandler extends BaseHandler implements Handler {
.phones(taskInfo.getReceiver()) .phones(taskInfo.getReceiver())
.content(getSmsContent(taskInfo)) .content(getSmsContent(taskInfo))
.messageTemplateId(taskInfo.getMessageTemplateId()) .messageTemplateId(taskInfo.getMessageTemplateId())
.sendAccountId(taskInfo.getSendAccount())
.build(); .build();
try { try {
/** /**
* 1 * 1
@ -66,15 +66,15 @@ public class SmsHandler extends BaseHandler implements Handler {
*/ */
MessageTypeSmsConfig[] messageTypeSmsConfigs = loadBalance(getMessageTypeSmsConfig(taskInfo.getMsgType())); MessageTypeSmsConfig[] messageTypeSmsConfigs = loadBalance(getMessageTypeSmsConfig(taskInfo.getMsgType()));
for (MessageTypeSmsConfig messageTypeSmsConfig : messageTypeSmsConfigs) { for (MessageTypeSmsConfig messageTypeSmsConfig : messageTypeSmsConfigs) {
List<SmsRecord> recordList = smsScriptHolder.route(messageTypeSmsConfig.getScriptName()).send(smsParam); smsParam.setScriptName(messageTypeSmsConfig.getScriptName());
List<SmsRecord> recordList = smsScripts.get(messageTypeSmsConfig.getScriptName()).send(smsParam);
if (CollUtil.isNotEmpty(recordList)) { if (CollUtil.isNotEmpty(recordList)) {
smsRecordDao.saveAll(recordList); smsRecordDao.saveAll(recordList);
return true; return true;
} }
} }
} catch (Exception e) { } catch (Exception e) {
log.error("SmsHandler#handler fail:{},params:{}", log.error("SmsHandler#handler fail:{},params:{}", Throwables.getStackTraceAsString(e), JSON.toJSONString(smsParam));
Throwables.getStackTraceAsString(e), JSON.toJSONString(smsParam));
} }
return false; return false;
} }
@ -129,14 +129,10 @@ public class SmsHandler extends BaseHandler implements Handler {
* @return * @return
*/ */
private List<MessageTypeSmsConfig> getMessageTypeSmsConfig(Integer msgType) { private List<MessageTypeSmsConfig> getMessageTypeSmsConfig(Integer msgType) {
String property = config.getProperty(FLOW_KEY, CommonConstant.EMPTY_VALUE_JSON_ARRAY);
String apolloKey = "msgTypeSmsConfig";
String messagePrefix = "message_type_";
String property = config.getProperty(apolloKey, AustinConstant.APOLLO_DEFAULT_VALUE_JSON_ARRAY);
JSONArray jsonArray = JSON.parseArray(property); JSONArray jsonArray = JSON.parseArray(property);
for (int i = 0; i < jsonArray.size(); i++) { for (int i = 0; i < jsonArray.size(); i++) {
JSONArray array = jsonArray.getJSONObject(i).getJSONArray(messagePrefix + msgType); JSONArray array = jsonArray.getJSONObject(i).getJSONArray(FLOW_KEY_PREFIX + msgType);
if (CollUtil.isNotEmpty(array)) { if (CollUtil.isNotEmpty(array)) {
List<MessageTypeSmsConfig> result = JSON.parseArray(JSON.toJSONString(array), MessageTypeSmsConfig.class); List<MessageTypeSmsConfig> result = JSON.parseArray(JSON.toJSONString(array), MessageTypeSmsConfig.class);
return result; return result;
@ -154,7 +150,7 @@ public class SmsHandler extends BaseHandler implements Handler {
private String getSmsContent(TaskInfo taskInfo) { private String getSmsContent(TaskInfo taskInfo) {
SmsContentModel smsContentModel = (SmsContentModel) taskInfo.getContentModel(); SmsContentModel smsContentModel = (SmsContentModel) taskInfo.getContentModel();
if (StrUtil.isNotBlank(smsContentModel.getUrl())) { if (StrUtil.isNotBlank(smsContentModel.getUrl())) {
return smsContentModel.getContent() + " " + smsContentModel.getUrl(); return smsContentModel.getContent() + StrUtil.SPACE + smsContentModel.getUrl();
} else { } else {
return smsContentModel.getContent(); return smsContentModel.getContent();
} }

@ -32,7 +32,7 @@ public class DingDingWorkReceipt {
public void pull() { public void pull() {
// try { // try {
// for (int index = SendAccountConstant.START; true; index = index + SendAccountConstant.STEP) { // for (int index = SendAccountConstant.START; true; index = index + SendAccountConstant.STEP) {
// DingDingWorkNoticeAccount account = accountUtils.getAccount(index, SendAccountConstant.DING_DING_WORK_NOTICE_ACCOUNT_KEY, SendAccountConstant.DING_DING_WORK_NOTICE_PREFIX, DingDingWorkNoticeAccount.class); // DingDingWorkNoticeAccount account = accountUtils.getAccountById(index, SendAccountConstant.DING_DING_WORK_NOTICE_ACCOUNT_KEY, SendAccountConstant.DING_DING_WORK_NOTICE_PREFIX, DingDingWorkNoticeAccount.class);
// if (account == null) { // if (account == null) {
// break; // break;
// } // }

@ -5,9 +5,9 @@ import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.google.common.base.Throwables; import com.google.common.base.Throwables;
import com.java3y.austin.common.constant.AustinConstant; import com.java3y.austin.common.constant.CommonConstant;
import com.java3y.austin.common.dto.account.TencentSmsAccount; import com.java3y.austin.common.dto.account.sms.TencentSmsAccount;
import com.java3y.austin.common.dto.account.YunPianSmsAccount; import com.java3y.austin.common.dto.account.sms.YunPianSmsAccount;
import com.java3y.austin.common.enums.ChannelType; import com.java3y.austin.common.enums.ChannelType;
import com.java3y.austin.common.enums.SmsStatus; import com.java3y.austin.common.enums.SmsStatus;
import com.java3y.austin.common.enums.SmsSupplier; import com.java3y.austin.common.enums.SmsSupplier;
@ -52,7 +52,7 @@ public class SmsPullReceipt {
* eg accountList[{"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":"云片"}}] * eg accountList[{"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":"云片"}}]
*/ */
public void pull() { public void pull() {
List<ChannelAccount> channelAccountList = channelAccountDao.findAllByIsDeletedEqualsAndSendChannelEquals(AustinConstant.FALSE, ChannelType.SMS.getCode()); List<ChannelAccount> channelAccountList = channelAccountDao.findAllByIsDeletedEqualsAndSendChannelEquals(CommonConstant.FALSE, ChannelType.SMS.getCode());
for (ChannelAccount channelAccount : channelAccountList) { for (ChannelAccount channelAccount : channelAccountList) {
Integer supplierId = JSON.parseObject(channelAccount.getAccountConfig()).getInteger("supplierId"); Integer supplierId = JSON.parseObject(channelAccount.getAccountConfig()).getInteger("supplierId");
if (SmsSupplier.TENCENT.getCode().equals(supplierId)) { if (SmsSupplier.TENCENT.getCode().equals(supplierId)) {

@ -6,13 +6,10 @@ import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.google.common.base.Throwables; import com.google.common.base.Throwables;
import com.java3y.austin.common.constant.SendAccountConstant; import com.java3y.austin.common.dto.account.sms.TencentSmsAccount;
import com.java3y.austin.common.dto.account.TencentSmsAccount;
import com.java3y.austin.common.enums.SmsStatus; import com.java3y.austin.common.enums.SmsStatus;
import com.java3y.austin.handler.domain.sms.SmsParam; import com.java3y.austin.handler.domain.sms.SmsParam;
import com.java3y.austin.handler.script.BaseSmsScript;
import com.java3y.austin.handler.script.SmsScript; import com.java3y.austin.handler.script.SmsScript;
import com.java3y.austin.handler.script.SmsScriptHandler;
import com.java3y.austin.support.domain.SmsRecord; import com.java3y.austin.support.domain.SmsRecord;
import com.java3y.austin.support.utils.AccountUtils; import com.java3y.austin.support.utils.AccountUtils;
import com.tencentcloudapi.common.Credential; import com.tencentcloudapi.common.Credential;
@ -24,6 +21,7 @@ import com.tencentcloudapi.sms.v20210111.models.SendSmsResponse;
import com.tencentcloudapi.sms.v20210111.models.SendStatus; import com.tencentcloudapi.sms.v20210111.models.SendStatus;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
@ -38,8 +36,8 @@ import java.util.List;
*/ */
@Slf4j @Slf4j
@SmsScriptHandler("TencentSmsScript") @Component("TencentSmsScript")
public class TencentSmsScript extends BaseSmsScript implements SmsScript { public class TencentSmsScript implements SmsScript {
private static final Integer PHONE_NUM = 11; private static final Integer PHONE_NUM = 11;
@ -49,7 +47,7 @@ public class TencentSmsScript extends BaseSmsScript implements SmsScript {
@Override @Override
public List<SmsRecord> send(SmsParam smsParam) { public List<SmsRecord> send(SmsParam smsParam) {
try { try {
TencentSmsAccount tencentSmsAccount = accountUtils.getAccount(smsParam.getSendAccountId(), SendAccountConstant.SMS_ACCOUNT_KEY, SendAccountConstant.SMS_PREFIX, TencentSmsAccount.class); TencentSmsAccount tencentSmsAccount = accountUtils.getSmsAccountByScriptName(smsParam.getScriptName(), TencentSmsAccount.class);
SmsClient client = init(tencentSmsAccount); SmsClient client = init(tencentSmsAccount);
SendSmsRequest request = assembleReq(smsParam, tencentSmsAccount); SendSmsRequest request = assembleReq(smsParam, tencentSmsAccount);
SendSmsResponse response = client.SendSms(request); SendSmsResponse response = client.SendSms(request);

@ -8,19 +8,18 @@ import cn.hutool.http.Header;
import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.google.common.base.Throwables; import com.google.common.base.Throwables;
import com.java3y.austin.common.constant.SendAccountConstant; import com.java3y.austin.common.constant.CommonConstant;
import com.java3y.austin.common.dto.account.YunPianSmsAccount; import com.java3y.austin.common.dto.account.sms.YunPianSmsAccount;
import com.java3y.austin.common.enums.SmsStatus; import com.java3y.austin.common.enums.SmsStatus;
import com.java3y.austin.handler.domain.sms.SmsParam; import com.java3y.austin.handler.domain.sms.SmsParam;
import com.java3y.austin.handler.domain.sms.YunPianSendResult; import com.java3y.austin.handler.domain.sms.YunPianSendResult;
import com.java3y.austin.handler.script.BaseSmsScript;
import com.java3y.austin.handler.script.SmsScript; import com.java3y.austin.handler.script.SmsScript;
import com.java3y.austin.handler.script.SmsScriptHandler;
import com.java3y.austin.support.domain.SmsRecord; import com.java3y.austin.support.domain.SmsRecord;
import com.java3y.austin.support.utils.AccountUtils; import com.java3y.austin.support.utils.AccountUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.*; import java.util.*;
@ -30,8 +29,8 @@ import java.util.*;
* https://www.yunpian.com/official/document/sms/zh_CN/domestic_list * https://www.yunpian.com/official/document/sms/zh_CN/domestic_list
*/ */
@Slf4j @Slf4j
@SmsScriptHandler("YunPianSmsScript") @Component("YunPianSmsScript")
public class YunPianSmsScript extends BaseSmsScript implements SmsScript { public class YunPianSmsScript implements SmsScript {
@Autowired @Autowired
private AccountUtils accountUtils; private AccountUtils accountUtils;
@ -39,7 +38,7 @@ public class YunPianSmsScript extends BaseSmsScript implements SmsScript {
public List<SmsRecord> send(SmsParam smsParam) { public List<SmsRecord> send(SmsParam smsParam) {
try { try {
YunPianSmsAccount account = accountUtils.getAccount(smsParam.getSendAccountId(), SendAccountConstant.SMS_ACCOUNT_KEY, SendAccountConstant.SMS_PREFIX, YunPianSmsAccount.class); YunPianSmsAccount account = accountUtils.getSmsAccountByScriptName(smsParam.getScriptName(), YunPianSmsAccount.class);
Map<String, Object> params = assembleParam(smsParam, account); Map<String, Object> params = assembleParam(smsParam, account);
String result = HttpRequest.post(account.getUrl()) String result = HttpRequest.post(account.getUrl())
@ -91,7 +90,7 @@ public class YunPianSmsScript extends BaseSmsScript implements SmsScript {
.msgContent(smsParam.getContent()) .msgContent(smsParam.getContent())
.seriesId(datum.getSid()) .seriesId(datum.getSid())
.chargingNum(Math.toIntExact(datum.getCount())) .chargingNum(Math.toIntExact(datum.getCount()))
.status("0".equals(datum.getCode()) ? SmsStatus.SEND_SUCCESS.getCode() : SmsStatus.SEND_FAIL.getCode()) .status(CommonConstant.ZERO.equals(datum.getCode()) ? SmsStatus.SEND_SUCCESS.getCode() : SmsStatus.SEND_FAIL.getCode())
.reportContent(datum.getMsg()) .reportContent(datum.getMsg())
.created(Math.toIntExact(DateUtil.currentSeconds())) .created(Math.toIntExact(DateUtil.currentSeconds()))
.updated(Math.toIntExact(DateUtil.currentSeconds())) .updated(Math.toIntExact(DateUtil.currentSeconds()))

@ -33,9 +33,7 @@ public class MiniProgramAccountServiceImpl implements MiniProgramAccountService
@Override @Override
public void send(WeChatMiniProgramParam miniProgramParam) throws Exception { public void send(WeChatMiniProgramParam miniProgramParam) throws Exception {
WeChatMiniProgramAccount miniProgramAccount = accountUtils.getAccount(miniProgramParam.getSendAccount(), WeChatMiniProgramAccount miniProgramAccount = accountUtils.getAccountById(miniProgramParam.getSendAccount(),
SendAccountConstant.WECHAT_MINI_PROGRAM_ACCOUNT_KEY,
SendAccountConstant.WECHAT_MINI_PROGRAM_PREFIX,
WeChatMiniProgramAccount.class); WeChatMiniProgramAccount.class);
WxMaSubscribeService wxMaSubscribeService = initService(miniProgramAccount); WxMaSubscribeService wxMaSubscribeService = initService(miniProgramAccount);

@ -31,7 +31,7 @@ public class OfficialAccountServiceImpl implements OfficialAccountService {
@Override @Override
public List<String> send(WeChatOfficialParam officialParam) throws Exception { public List<String> send(WeChatOfficialParam officialParam) throws Exception {
WeChatOfficialAccount officialAccount = accountUtils.getAccount(officialParam.getSendAccount(), SendAccountConstant.WECHAT_OFFICIAL_ACCOUNT_KEY, SendAccountConstant.WECHAT_OFFICIAL__PREFIX, WeChatOfficialAccount.class); WeChatOfficialAccount officialAccount = accountUtils.getAccountById(officialParam.getSendAccount(),WeChatOfficialAccount.class);
WxMpService wxMpService = initService(officialAccount); WxMpService wxMpService = initService(officialAccount);
List<WxMpTemplateMessage> messages = assembleReq(officialParam, officialAccount); List<WxMpTemplateMessage> messages = assembleReq(officialParam, officialAccount);
List<String> messageIds = new ArrayList<>(messages.size()); List<String> messageIds = new ArrayList<>(messages.size());

@ -8,6 +8,7 @@ import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature; import com.alibaba.fastjson.serializer.SerializerFeature;
import com.google.common.base.Throwables; import com.google.common.base.Throwables;
import com.java3y.austin.common.constant.AustinConstant; import com.java3y.austin.common.constant.AustinConstant;
import com.java3y.austin.common.constant.CommonConstant;
import com.java3y.austin.common.domain.TaskInfo; import com.java3y.austin.common.domain.TaskInfo;
import com.java3y.austin.common.dto.model.ContentModel; import com.java3y.austin.common.dto.model.ContentModel;
import com.java3y.austin.common.enums.ChannelType; import com.java3y.austin.common.enums.ChannelType;
@ -38,6 +39,8 @@ import java.util.*;
@Service @Service
public class AssembleAction implements BusinessProcess<SendTaskModel> { public class AssembleAction implements BusinessProcess<SendTaskModel> {
private static final String LINK_NAME = "url";
@Autowired @Autowired
private MessageTemplateDao messageTemplateDao; private MessageTemplateDao messageTemplateDao;
@ -48,7 +51,7 @@ public class AssembleAction implements BusinessProcess<SendTaskModel> {
try { try {
Optional<MessageTemplate> messageTemplate = messageTemplateDao.findById(messageTemplateId); Optional<MessageTemplate> messageTemplate = messageTemplateDao.findById(messageTemplateId);
if (!messageTemplate.isPresent() || messageTemplate.get().getIsDeleted().equals(AustinConstant.TRUE)) { if (!messageTemplate.isPresent() || messageTemplate.get().getIsDeleted().equals(CommonConstant.TRUE)) {
context.setNeedBreak(true).setResponse(BasicResultVO.fail(RespStatusEnum.TEMPLATE_NOT_FOUND)); context.setNeedBreak(true).setResponse(BasicResultVO.fail(RespStatusEnum.TEMPLATE_NOT_FOUND));
return; return;
} }
@ -126,10 +129,10 @@ public class AssembleAction implements BusinessProcess<SendTaskModel> {
} }
// 如果 url 字段存在则在url拼接对应的埋点参数 // 如果 url 字段存在则在url拼接对应的埋点参数
String url = (String) ReflectUtil.getFieldValue(contentModel, "url"); String url = (String) ReflectUtil.getFieldValue(contentModel, LINK_NAME);
if (StrUtil.isNotBlank(url)) { if (StrUtil.isNotBlank(url)) {
String resultUrl = TaskInfoUtils.generateUrl(url, messageTemplate.getId(), messageTemplate.getTemplateType()); String resultUrl = TaskInfoUtils.generateUrl(url, messageTemplate.getId(), messageTemplate.getTemplateType());
ReflectUtil.setFieldValue(contentModel, "url", resultUrl); ReflectUtil.setFieldValue(contentModel, LINK_NAME, resultUrl);
} }
return contentModel; return contentModel;
} }

@ -2,6 +2,7 @@ package com.java3y.austin.service.api.impl.action;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.java3y.austin.common.constant.AustinConstant;
import com.java3y.austin.common.enums.RespStatusEnum; import com.java3y.austin.common.enums.RespStatusEnum;
import com.java3y.austin.common.vo.BasicResultVO; import com.java3y.austin.common.vo.BasicResultVO;
import com.java3y.austin.service.api.domain.MessageParam; import com.java3y.austin.service.api.domain.MessageParam;
@ -24,11 +25,6 @@ import java.util.stream.Collectors;
@Service @Service
public class PreParamCheckAction implements BusinessProcess<SendTaskModel> { public class PreParamCheckAction implements BusinessProcess<SendTaskModel> {
/**
*
*/
private static final Integer BATCH_RECEIVER_SIZE = 100;
@Override @Override
public void process(ProcessContext<SendTaskModel> context) { public void process(ProcessContext<SendTaskModel> context) {
SendTaskModel sendTaskModel = context.getProcessModel(); SendTaskModel sendTaskModel = context.getProcessModel();
@ -50,13 +46,14 @@ public class PreParamCheckAction implements BusinessProcess<SendTaskModel> {
context.setNeedBreak(true).setResponse(BasicResultVO.fail(RespStatusEnum.CLIENT_BAD_PARAMETERS)); context.setNeedBreak(true).setResponse(BasicResultVO.fail(RespStatusEnum.CLIENT_BAD_PARAMETERS));
return; return;
} }
sendTaskModel.setMessageParamList(resultMessageParamList);
// 3.过滤receiver大于100的请求 // 3.过滤receiver大于100的请求
if (messageParamList.stream().anyMatch(messageParam -> messageParam.getReceiver().split(StrUtil.COMMA).length > BATCH_RECEIVER_SIZE)) { if (resultMessageParamList.stream().anyMatch(messageParam -> messageParam.getReceiver().split(StrUtil.COMMA).length > AustinConstant.BATCH_RECEIVER_SIZE)) {
context.setNeedBreak(true).setResponse(BasicResultVO.fail(RespStatusEnum.TOO_MANY_RECEIVER)); context.setNeedBreak(true).setResponse(BasicResultVO.fail(RespStatusEnum.TOO_MANY_RECEIVER));
return; return;
} }
sendTaskModel.setMessageParamList(resultMessageParamList);
} }
} }

@ -35,4 +35,5 @@ public interface ChannelAccountDao extends JpaRepository<ChannelAccount, Long> {
* @return * @return
*/ */
Long countByIsDeletedEquals(Integer deleted); Long countByIsDeletedEquals(Integer deleted);
} }

@ -20,7 +20,7 @@ public interface MessageTemplateDao extends JpaRepository<MessageTemplate, Long>
* @param pageable * @param pageable
* @return * @return
*/ */
List<MessageTemplate> findAllByIsDeletedEquals(Integer deleted, Pageable pageable); List<MessageTemplate> findAllByIsDeletedEqualsOrderByUpdatedDesc(Integer deleted, Pageable pageable);
/** /**

@ -40,7 +40,7 @@ public abstract class AbstractLazyPending<T> {
/** /**
* 线 * 线
*/ */
private Boolean stop = false; private volatile Boolean stop = false;
/** /**
* 线 * 线

@ -5,6 +5,9 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.google.common.base.Throwables; import com.google.common.base.Throwables;
import com.java3y.austin.common.constant.AustinConstant; import com.java3y.austin.common.constant.AustinConstant;
import com.java3y.austin.common.constant.CommonConstant;
import com.java3y.austin.common.dto.account.sms.SmsAccount;
import com.java3y.austin.common.enums.ChannelType;
import com.java3y.austin.support.dao.ChannelAccountDao; import com.java3y.austin.support.dao.ChannelAccountDao;
import com.java3y.austin.support.domain.ChannelAccount; import com.java3y.austin.support.domain.ChannelAccount;
import com.java3y.austin.support.service.ConfigService; import com.java3y.austin.support.service.ConfigService;
@ -12,6 +15,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Optional; import java.util.Optional;
/** /**
@ -31,6 +35,7 @@ public class AccountUtils {
/** /**
* local.properties
* (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: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":"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: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:enterpriseWechatAccount)[{"enterprise_wechat_10":{"corpId":"wwf87603333e00069c","corpSecret":"-IFWxS2222QxzPIorNV11144D915DM","agentId":10044442,"token":"rXROB3333Kf6i","aesKey":"MKZtoFxHIM44444M7ieag3r9ZPUsl"}}]
@ -38,12 +43,10 @@ public class AccountUtils {
* (key:dingDingWorkNoticeAccount) [{"ding_ding_work_notice_10":{"appKey":"dingh6yyyyyyycrlbx","appSecret":"tQpvmkR863333yyyyyHP3QHyyyymy9Ao1yoL1oQX5NsdfsWHvWKbTu","agentId":"1523123123183622"}}] * (key:dingDingWorkNoticeAccount) [{"ding_ding_work_notice_10":{"appKey":"dingh6yyyyyyycrlbx","appSecret":"tQpvmkR863333yyyyyHP3QHyyyymy9Ao1yoL1oQX5NsdfsWHvWKbTu","agentId":"1523123123183622"}}]
* (key:officialAccount) [{"official_10":{"appId":"wxecb4693d2eef1ea7","secret":"624asdfsa1640d769ba20120821","templateId":"JHUk6eE9T5Ts7asdfsadfiKNDQsk-Q","url":"http://weixin.qq.com/download","miniProgramId":"xiaochengxuappid12345","path":"index?foo=bar"}}] * (key:officialAccount) [{"official_10":{"appId":"wxecb4693d2eef1ea7","secret":"624asdfsa1640d769ba20120821","templateId":"JHUk6eE9T5Ts7asdfsadfiKNDQsk-Q","url":"http://weixin.qq.com/download","miniProgramId":"xiaochengxuappid12345","path":"index?foo=bar"}}]
* (key:miniProgramAccount) [{"mini_program_10":{"appId":"wxecb4693d2eef1ea7","appSecret":"6240870f4d91701640d769ba20120821","templateId":"JHUk6eE9T5TasdfCrQsk-Q","grantType":"client_credential","miniProgramState":"trial","page":"index?foo=bar"}}] * (key:miniProgramAccount) [{"mini_program_10":{"appId":"wxecb4693d2eef1ea7","appSecret":"6240870f4d91701640d769ba20120821","templateId":"JHUk6eE9T5TasdfCrQsk-Q","grantType":"client_credential","miniProgramState":"trial","page":"index?foo=bar"}}]
* (key:alipayMiniProgramAccount) [{"alipay_mini_program_10":{"privateKey":"MIIEvQIBADANB......","alipayPublicKey":"MIIBIjANBg...","appId":"2014********7148","userTemplateId":"MDI4YzIxMDE2M2I5YTQzYjUxNWE4MjA4NmU1MTIyYmM=","page":"page/component/index"}}]
*/ */
public <T> T getAccount(Integer sendAccountId, String apolloKey, String prefix, Class<T> clazz) { public <T> T getAccountById(Integer sendAccountId, Class<T> clazz) {
/**
*
*/
try { try {
Optional<ChannelAccount> optionalChannelAccount = channelAccountDao.findById(Long.valueOf(sendAccountId)); Optional<ChannelAccount> optionalChannelAccount = channelAccountDao.findById(Long.valueOf(sendAccountId));
if (optionalChannelAccount.isPresent()) { if (optionalChannelAccount.isPresent()) {
@ -51,19 +54,39 @@ public class AccountUtils {
return JSON.parseObject(channelAccount.getAccountConfig(), clazz); return JSON.parseObject(channelAccount.getAccountConfig(), clazz);
} }
} catch (Exception e) { } catch (Exception e) {
log.warn("AccountUtils#getAccount not found:{}", Throwables.getStackTraceAsString(e)); log.error("AccountUtils#getAccount fail!", Throwables.getStackTraceAsString(e));
} }
log.error("AccountUtils#getAccount not found!:{}", sendAccountId);
return null;
}
String accountValues = config.getProperty(apolloKey, AustinConstant.APOLLO_DEFAULT_VALUE_JSON_ARRAY); /**
JSONArray jsonArray = JSON.parseArray(accountValues); *
for (int i = 0; i < jsonArray.size(); i++) { * @param scriptName
JSONObject jsonObject = jsonArray.getJSONObject(i); * @param clazz
T object = jsonObject.getObject(prefix + sendAccountId, clazz); * @param <T>
if (object != null) { * @return
return object; */
public <T> T getSmsAccountByScriptName(String scriptName, Class<T> clazz) {
try {
List<ChannelAccount> channelAccountList = channelAccountDao.findAllByIsDeletedEqualsAndSendChannelEquals(CommonConstant.FALSE, ChannelType.SMS.getCode());
for (ChannelAccount channelAccount : channelAccountList) {
try {
SmsAccount smsAccount = JSON.parseObject(channelAccount.getAccountConfig(), SmsAccount.class);
if (smsAccount.getScriptName().equals(scriptName)) {
return JSON.parseObject(channelAccount.getAccountConfig(), clazz);
}
} catch (Exception e) {
log.error("AccountUtils#getSmsAccount parse fail! e:{},account:{}", Throwables.getStackTraceAsString(e), JSON.toJSONString(channelAccount));
}
} }
} catch (Exception e) {
log.error("AccountUtils#getSmsAccount fail! e:{}", Throwables.getStackTraceAsString(e));
} }
log.error("AccountUtils#getSmsAccount not found!:{}", scriptName);
return null; return null;
} }
} }

@ -24,6 +24,10 @@ import java.util.Properties;
public class NacosUtils { public class NacosUtils {
@Value("${austin.nacos.server}") @Value("${austin.nacos.server}")
private String nacosServer; private String nacosServer;
@Value("${austin.nacos.username}")
private String nacosUsername;
@Value("${austin.nacos.password}")
private String nacosPassword;
@Value("${austin.nacos.group}") @Value("${austin.nacos.group}")
private String nacosGroup; private String nacosGroup;
@Value("${austin.nacos.dataId}") @Value("${austin.nacos.dataId}")
@ -51,6 +55,8 @@ public class NacosUtils {
try { try {
request.put(PropertyKeyConst.SERVER_ADDR, nacosServer); request.put(PropertyKeyConst.SERVER_ADDR, nacosServer);
request.put(PropertyKeyConst.NAMESPACE, nacosNamespace); request.put(PropertyKeyConst.NAMESPACE, nacosNamespace);
request.put(PropertyKeyConst.USERNAME,nacosUsername);
request.put(PropertyKeyConst.PASSWORD,nacosPassword);
context = NacosFactory.createConfigService(request) context = NacosFactory.createConfigService(request)
.getConfig(nacosDataId, nacosGroup, 5000); .getConfig(nacosDataId, nacosGroup, 5000);
} catch (NacosException e) { } catch (NacosException e) {

@ -3,6 +3,7 @@ package com.java3y.austin.support.utils;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import com.google.common.base.Throwables; import com.google.common.base.Throwables;
import com.java3y.austin.common.constant.AustinConstant; import com.java3y.austin.common.constant.AustinConstant;
import com.java3y.austin.common.constant.CommonConstant;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisCallback; import org.springframework.data.redis.core.RedisCallback;
@ -170,7 +171,7 @@ public class RedisUtils {
try { try {
Long execute = redisTemplate.execute(redisScript, keys, args); Long execute = redisTemplate.execute(redisScript, keys, args);
return AustinConstant.TRUE.equals(execute.intValue()); return CommonConstant.TRUE.equals(execute.intValue());
} catch (Exception e) { } catch (Exception e) {
log.error("redis execLimitLua fail! e:{}", Throwables.getStackTraceAsString(e)); log.error("redis execLimitLua fail! e:{}", Throwables.getStackTraceAsString(e));

@ -2,6 +2,8 @@ package com.java3y.austin.support.utils;
import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.java3y.austin.common.constant.CommonConstant;
import java.util.Date; import java.util.Date;
@ -13,7 +15,7 @@ import java.util.Date;
public class TaskInfoUtils { public class TaskInfoUtils {
private static final int TYPE_FLAG = 1000000; private static final int TYPE_FLAG = 1000000;
private static final char PARAM = '?'; private static final String CODE = "track_code_bid";
/** /**
* BusinessId * BusinessId
@ -45,10 +47,10 @@ public class TaskInfoUtils {
public static String generateUrl(String url, Long templateId, Integer templateType) { public static String generateUrl(String url, Long templateId, Integer templateType) {
url = url.trim(); url = url.trim();
Long businessId = generateBusinessId(templateId, templateType); Long businessId = generateBusinessId(templateId, templateType);
if (url.indexOf(PARAM) == -1) { if (url.indexOf(CommonConstant.QM) == -1) {
return url + "?track_code_bid=" + businessId; return url + CommonConstant.QM_STRING + CODE + CommonConstant.EQUAL_STRING + businessId;
} else { } else {
return url + "&track_code_bid=" + businessId; return url + CommonConstant.AND_STRING + CODE + CommonConstant.EQUAL_STRING + businessId;
} }
} }

@ -23,6 +23,8 @@ public class SwaggerConfiguration {
/** /**
* C * C
* *
* http://localhost:8080/swagger-ui/index.html
*
* @return * @return
*/ */
@Bean @Bean

@ -2,6 +2,7 @@ package com.java3y.austin.web.controller;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.java3y.austin.common.constant.AustinConstant;
import com.java3y.austin.common.vo.BasicResultVO; import com.java3y.austin.common.vo.BasicResultVO;
import com.java3y.austin.support.domain.ChannelAccount; import com.java3y.austin.support.domain.ChannelAccount;
import com.java3y.austin.web.service.ChannelAccountService; import com.java3y.austin.web.service.ChannelAccountService;
@ -11,8 +12,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.Arrays; import java.util.*;
import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -24,7 +24,7 @@ import java.util.stream.Collectors;
@RestController @RestController
@RequestMapping("/account") @RequestMapping("/account")
@Api("渠道账号管理接口") @Api("渠道账号管理接口")
@CrossOrigin(origins = "http://localhost:3000", allowCredentials = "true", allowedHeaders = "*") @CrossOrigin(origins = AustinConstant.ORIGIN_VALUE, allowCredentials = "true", allowedHeaders = "*")
public class ChannelAccountController { public class ChannelAccountController {
@Autowired @Autowired
@ -47,7 +47,16 @@ public class ChannelAccountController {
@GetMapping("/queryByChannelType") @GetMapping("/queryByChannelType")
@ApiOperation("/根据渠道标识查询相关的记录") @ApiOperation("/根据渠道标识查询相关的记录")
public BasicResultVO query(Integer channelType) { public BasicResultVO query(Integer channelType) {
return BasicResultVO.success(channelAccountService.queryByChannelType(channelType)); List<ChannelAccount> channelAccounts = channelAccountService.queryByChannelType(channelType);
List<Map<String, String>> result = new ArrayList<>();
for (ChannelAccount channelAccount : channelAccounts) {
HashMap<String, String> optionKV = new HashMap<>();
optionKV.put("label", channelAccount.getName());
optionKV.put("value", String.valueOf(channelAccount.getId()));
result.add(optionKV);
}
return BasicResultVO.success(result);
} }
/** /**

@ -1,6 +1,7 @@
package com.java3y.austin.web.controller; package com.java3y.austin.web.controller;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.java3y.austin.common.constant.AustinConstant;
import com.java3y.austin.common.enums.RespStatusEnum; import com.java3y.austin.common.enums.RespStatusEnum;
import com.java3y.austin.common.vo.BasicResultVO; import com.java3y.austin.common.vo.BasicResultVO;
import com.java3y.austin.web.service.DataService; import com.java3y.austin.web.service.DataService;
@ -23,7 +24,7 @@ import org.springframework.web.bind.annotation.*;
@RestController @RestController
@RequestMapping("/trace") @RequestMapping("/trace")
@Api("获取数据接口(全链路追踪)") @Api("获取数据接口(全链路追踪)")
@CrossOrigin(origins = "http://localhost:3000", allowCredentials = "true", allowedHeaders = "*") @CrossOrigin(origins = AustinConstant.ORIGIN_VALUE, allowCredentials = "true", allowedHeaders = "*")
public class DataController { public class DataController {
@Autowired @Autowired
private DataService dataService; private DataService dataService;

@ -7,6 +7,7 @@ import com.dingtalk.api.DefaultDingTalkClient;
import com.dingtalk.api.DingTalkClient; import com.dingtalk.api.DingTalkClient;
import com.dingtalk.api.request.OapiMediaUploadRequest; import com.dingtalk.api.request.OapiMediaUploadRequest;
import com.dingtalk.api.response.OapiMediaUploadResponse; import com.dingtalk.api.response.OapiMediaUploadResponse;
import com.java3y.austin.common.constant.AustinConstant;
import com.java3y.austin.common.constant.SendAccountConstant; import com.java3y.austin.common.constant.SendAccountConstant;
import com.java3y.austin.common.enums.ChannelType; import com.java3y.austin.common.enums.ChannelType;
import com.java3y.austin.common.enums.FileType; import com.java3y.austin.common.enums.FileType;
@ -26,15 +27,16 @@ import org.springframework.web.multipart.MultipartFile;
/** /**
* *
*
* @author 3y * @author 3y
*/ */
@Slf4j @Slf4j
@RestController @RestController
@RequestMapping("/material") @RequestMapping("/material")
@Api("素材管理接口") @Api("素材管理接口")
@CrossOrigin(origins = "http://localhost:3000", allowCredentials = "true", allowedHeaders = "*") @CrossOrigin(origins = AustinConstant.ORIGIN_VALUE, allowCredentials = "true", allowedHeaders = "*")
public class MaterialController {
public class MaterialController {
@Autowired @Autowired
private MaterialService materialService; private MaterialService materialService;

@ -5,6 +5,7 @@ import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.google.common.base.Throwables; import com.google.common.base.Throwables;
import com.java3y.austin.common.constant.AustinConstant;
import com.java3y.austin.common.enums.RespStatusEnum; import com.java3y.austin.common.enums.RespStatusEnum;
import com.java3y.austin.common.vo.BasicResultVO; import com.java3y.austin.common.vo.BasicResultVO;
import com.java3y.austin.service.api.domain.MessageParam; import com.java3y.austin.service.api.domain.MessageParam;
@ -23,6 +24,7 @@ import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@ -42,7 +44,7 @@ import java.util.stream.Collectors;
@RestController @RestController
@RequestMapping("/messageTemplate") @RequestMapping("/messageTemplate")
@Api("发送消息") @Api("发送消息")
@CrossOrigin(origins = "http://localhost:3000", allowCredentials = "true", allowedHeaders = "*") @CrossOrigin(origins = AustinConstant.ORIGIN_VALUE, allowCredentials = "true", allowedHeaders = "*")
public class MessageTemplateController { public class MessageTemplateController {
@Autowired @Autowired
@ -73,7 +75,7 @@ public class MessageTemplateController {
*/ */
@GetMapping("/list") @GetMapping("/list")
@ApiOperation("/列表页") @ApiOperation("/列表页")
public BasicResultVO queryList(MessageTemplateParam messageTemplateParam) { public BasicResultVO queryList(@Validated MessageTemplateParam messageTemplateParam) {
List<Map<String, Object>> result = ConvertMap.flatList(messageTemplateService.queryList(messageTemplateParam)); List<Map<String, Object>> result = ConvertMap.flatList(messageTemplateService.queryList(messageTemplateParam));
long count = messageTemplateService.count(); long count = messageTemplateService.count();

@ -2,6 +2,7 @@ package com.java3y.austin.web.service.impl;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.java3y.austin.common.constant.AustinConstant; import com.java3y.austin.common.constant.AustinConstant;
import com.java3y.austin.common.constant.CommonConstant;
import com.java3y.austin.support.dao.ChannelAccountDao; import com.java3y.austin.support.dao.ChannelAccountDao;
import com.java3y.austin.support.domain.ChannelAccount; import com.java3y.austin.support.domain.ChannelAccount;
import com.java3y.austin.web.service.ChannelAccountService; import com.java3y.austin.web.service.ChannelAccountService;
@ -22,7 +23,7 @@ public class ChannelAccountServiceImpl implements ChannelAccountService {
public ChannelAccount save(ChannelAccount channelAccount) { public ChannelAccount save(ChannelAccount channelAccount) {
if (channelAccount.getId() == null) { if (channelAccount.getId() == null) {
channelAccount.setCreated(Math.toIntExact(DateUtil.currentSeconds())); channelAccount.setCreated(Math.toIntExact(DateUtil.currentSeconds()));
channelAccount.setIsDeleted(AustinConstant.FALSE); channelAccount.setIsDeleted(CommonConstant.FALSE);
} }
channelAccount.setUpdated(Math.toIntExact(DateUtil.currentSeconds())); channelAccount.setUpdated(Math.toIntExact(DateUtil.currentSeconds()));
return channelAccountDao.save(channelAccount); return channelAccountDao.save(channelAccount);
@ -30,7 +31,7 @@ public class ChannelAccountServiceImpl implements ChannelAccountService {
@Override @Override
public List<ChannelAccount> queryByChannelType(Integer channelType) { public List<ChannelAccount> queryByChannelType(Integer channelType) {
return channelAccountDao.findAllByIsDeletedEqualsAndSendChannelEquals(AustinConstant.FALSE, channelType); return channelAccountDao.findAllByIsDeletedEqualsAndSendChannelEquals(CommonConstant.FALSE, channelType);
} }
@Override @Override

@ -4,6 +4,7 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.java3y.austin.common.constant.AustinConstant; import com.java3y.austin.common.constant.AustinConstant;
import com.java3y.austin.common.constant.CommonConstant;
import com.java3y.austin.common.enums.AuditStatus; import com.java3y.austin.common.enums.AuditStatus;
import com.java3y.austin.common.enums.MessageStatus; import com.java3y.austin.common.enums.MessageStatus;
import com.java3y.austin.common.enums.RespStatusEnum; import com.java3y.austin.common.enums.RespStatusEnum;
@ -44,12 +45,12 @@ public class MessageTemplateServiceImpl implements MessageTemplateService {
@Override @Override
public List<MessageTemplate> queryList(MessageTemplateParam param) { public List<MessageTemplate> queryList(MessageTemplateParam param) {
PageRequest pageRequest = PageRequest.of(param.getPage() - 1, param.getPerPage()); PageRequest pageRequest = PageRequest.of(param.getPage() - 1, param.getPerPage());
return messageTemplateDao.findAllByIsDeletedEquals(AustinConstant.FALSE, pageRequest); return messageTemplateDao.findAllByIsDeletedEqualsOrderByUpdatedDesc(CommonConstant.FALSE, pageRequest);
} }
@Override @Override
public Long count() { public Long count() {
return messageTemplateDao.countByIsDeletedEquals(AustinConstant.FALSE); return messageTemplateDao.countByIsDeletedEquals(CommonConstant.FALSE);
} }
@Override @Override
@ -68,7 +69,7 @@ public class MessageTemplateServiceImpl implements MessageTemplateService {
@Override @Override
public void deleteByIds(List<Long> ids) { public void deleteByIds(List<Long> ids) {
Iterable<MessageTemplate> messageTemplates = messageTemplateDao.findAllById(ids); Iterable<MessageTemplate> messageTemplates = messageTemplateDao.findAllById(ids);
messageTemplates.forEach(messageTemplate -> messageTemplate.setIsDeleted(AustinConstant.TRUE)); messageTemplates.forEach(messageTemplate -> messageTemplate.setIsDeleted(CommonConstant.TRUE));
for (MessageTemplate messageTemplate : messageTemplates) { for (MessageTemplate messageTemplate : messageTemplates) {
if (messageTemplate.getCronTaskId()!=null && messageTemplate.getCronTaskId() > 0) { if (messageTemplate.getCronTaskId()!=null && messageTemplate.getCronTaskId() > 0) {
cronTaskService.deleteCronTask(messageTemplate.getCronTaskId()); cronTaskService.deleteCronTask(messageTemplate.getCronTaskId());
@ -137,7 +138,7 @@ public class MessageTemplateServiceImpl implements MessageTemplateService {
.setMsgStatus(MessageStatus.INIT.getCode()).setAuditStatus(AuditStatus.WAIT_AUDIT.getCode()) .setMsgStatus(MessageStatus.INIT.getCode()).setAuditStatus(AuditStatus.WAIT_AUDIT.getCode())
.setCreator("Java3y").setUpdator("Java3y").setTeam("公众号Java3y").setAuditor("3y") .setCreator("Java3y").setUpdator("Java3y").setTeam("公众号Java3y").setAuditor("3y")
.setCreated(Math.toIntExact(DateUtil.currentSeconds())) .setCreated(Math.toIntExact(DateUtil.currentSeconds()))
.setIsDeleted(AustinConstant.FALSE); .setIsDeleted(CommonConstant.FALSE);
} }

@ -5,6 +5,9 @@ import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import javax.validation.constraints.NotNull;
/** /**
* *
* *
@ -20,11 +23,13 @@ public class MessageTemplateParam {
/** /**
* *
*/ */
@NotNull
private Integer page; private Integer page;
/** /**
* *
*/ */
@NotNull
private Integer perPage; private Integer perPage;
/** /**

@ -122,6 +122,8 @@ apollo.bootstrap.namespaces=boss.austin,dynamic-tp-apollo-dtp.yml
########################################## nacos start ########################################## ########################################## nacos start ##########################################
austin.nacos.server= austin.nacos.server=
austin.nacos.username=
austin.nacos.password=
austin.nacos.dataId=austin austin.nacos.dataId=austin
austin.nacos.group=DEFAULT_GROUP austin.nacos.group=DEFAULT_GROUP
austin.nacos.namespace=9537c674-f3a6-4203-b286-ef0c36bfacb2 austin.nacos.namespace=9537c674-f3a6-4203-b286-ef0c36bfacb2

@ -1,11 +1,4 @@
discardMsgIds = [] discardMsgIds = []
deduplicationRule = {"deduplication_10":{"num":1,"time":300},"deduplication_20":{"num":5}} deduplicationRule = {"deduplication_10":{"num":1,"time":300},"deduplication_20":{"num":5}}
emailAccount = [{"email_10":{"host":"smtp.qq.com","port":465,"user":"23423432@qq.com","pass":"234324324","from":"123123@qq.com","starttlsEnable":"true","auth":true,"sslEnable":true}},{"email_20":{"host":"smtp.163.com","port":465,"user":"23423423@163.com","pass":"234234324","from":"112312312@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"}}]
flowControlRule = {"flow_control_40":1}
geTuiAccount = [{"ge_tui_account_10":{"appId":"23423423","appKey":"234234234","masterSecret":"2342342342342"}}]
feiShuAccountRobot = [{"fei_shu_robot_10":{"webhook":"https://open.feishu.cn/open-apis/bot/v2/hook/c24b09ef-9aa3-4aad-9239-a7e05fcaf6ec"}}]
msgTypeSmsConfig = [{"message_type_10":[{"weights":99,"scriptName":"TencentSmsScript"},{"weights":1,"scriptName":"YunPianSmsScript"}]},{"message_type_20":[{"weights":99,"scriptName":"TencentSmsScript"},{"weights":1,"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":99,"scriptName":"TencentSmsScript"},{"weights":1,"scriptName":"YunPianSmsScript"}]},{"message_type_30":[{"weights":20,"scriptName":"TencentSmsScript"}]},{"message_type_40":[{"weights":20,"scriptName":"TencentSmsScript"}]}]
flowControl = {"flow_control_40":1}

@ -0,0 +1,18 @@
version: '3'
services:
rabbitmq:
image: registry.cn-hangzhou.aliyuncs.com/zhengqing/rabbitmq:3.7.8-management # 原镜像`rabbitmq:3.7.8-management` 【 注该版本包含了web控制页面 】
container_name: rabbitmq # 容器名为'rabbitmq'
hostname: my-rabbit
restart: unless-stopped # 指定容器退出后的重启策略为始终重启但是不考虑在Docker守护进程启动时就已经停止了的容器
environment: # 设置环境变量,相当于docker run命令中的-e
TZ: Asia/Shanghai
LANG: en_US.UTF-8
RABBITMQ_DEFAULT_VHOST: my_vhost # 主机名
RABBITMQ_DEFAULT_USER: admin # 登录账号
RABBITMQ_DEFAULT_PASS: admin # 登录密码
volumes: # 数据卷挂载路径设置,将本机目录映射到容器目录
- "./rabbitmq/data:/var/lib/rabbitmq"
ports: # 映射端口
- "5672:5672"
- "15672:15672"

@ -0,0 +1,47 @@
# 环境变量可参考: https://www.rabbitmq.com/configure.html
# https://github.com/rabbitmq/rabbitmq-server/blob/master/deps/rabbit/docs/rabbitmq.conf.example
# https://www.rabbitmq.com/clustering.html#erlang-cookie
version: '3'
# 网桥 -> 方便相互通讯
networks:
rabbitmq:
driver: bridge
services:
rabbitmq-1:
image: registry.cn-hangzhou.aliyuncs.com/zhengqing/rabbitmq:3.9.1-management # 镜像`rabbitmq:3.9.1-management` 【 注该版本包含了web控制页面 】
container_name: rabbitmq-1 # 容器名为'rabbitmq-1'
hostname: my-rabbit-1
restart: unless-stopped # 指定容器退出后的重启策略为始终重启但是不考虑在Docker守护进程启动时就已经停止了的容器
environment: # 设置环境变量,相当于docker run命令中的-e
TZ: Asia/Shanghai
LANG: en_US.UTF-8
volumes: # 数据卷挂载路径设置,将本机目录映射到容器目录
- "./rabbitmq-cluster/rabbitmq-1/config/rabbitmq.conf:/etc/rabbitmq/rabbitmq.conf"
- "./rabbitmq-cluster/rabbitmq-1/data:/var/lib/rabbitmq"
- "./rabbitmq-cluster/plugins/rabbitmq_delayed_message_exchange-3.9.0.ez:/opt/rabbitmq/plugins/rabbitmq_delayed_message_exchange-3.9.0.ez"
- "./rabbitmq-cluster/.erlang.cookie:/var/lib/rabbitmq/.erlang.cookie"
ports: # 映射端口
- "5672:5672"
- "15672:15672"
networks:
- rabbitmq
rabbitmq-2:
image: registry.cn-hangzhou.aliyuncs.com/zhengqing/rabbitmq:3.9.1-management # 镜像`rabbitmq:3.9.1-management` 【 注该版本包含了web控制页面 】
container_name: rabbitmq-2 # 容器名为'rabbitmq-2'
hostname: my-rabbit-2
restart: unless-stopped # 指定容器退出后的重启策略为始终重启但是不考虑在Docker守护进程启动时就已经停止了的容器
environment: # 设置环境变量,相当于docker run命令中的-e
TZ: Asia/Shanghai
LANG: en_US.UTF-8
volumes: # 数据卷挂载路径设置,将本机目录映射到容器目录
- "./rabbitmq-cluster/rabbitmq-2/config/rabbitmq.conf:/etc/rabbitmq/rabbitmq.conf"
- "./rabbitmq-cluster/rabbitmq-2/data:/var/lib/rabbitmq"
- "./rabbitmq-cluster/plugins/rabbitmq_delayed_message_exchange-3.9.0.ez:/opt/rabbitmq/plugins/rabbitmq_delayed_message_exchange-3.9.0.ez"
- "./rabbitmq-cluster/.erlang.cookie:/var/lib/rabbitmq/.erlang.cookie"
ports: # 映射端口
- "5673:5672"
networks:
- rabbitmq

@ -0,0 +1,21 @@
# 环境变量可参考: https://www.rabbitmq.com/configure.html
# https://github.com/rabbitmq/rabbitmq-server/blob/master/deps/rabbit/docs/rabbitmq.conf.example
version: '3'
services:
rabbitmq:
image: registry.cn-hangzhou.aliyuncs.com/zhengqing/rabbitmq:3.9.15-management # 镜像`rabbitmq:3.9.1-management` 【 注该版本包含了web控制页面 】
container_name: rabbitmq # 容器名为'rabbitmq'
hostname: my-rabbit
restart: unless-stopped # 指定容器退出后的重启策略为始终重启但是不考虑在Docker守护进程启动时就已经停止了的容器
environment: # 设置环境变量,相当于docker run命令中的-e
TZ: Asia/Shanghai
LANG: en_US.UTF-8
volumes: # 数据卷挂载路径设置,将本机目录映射到容器目录
- "./rabbitmq/config/rabbitmq.conf:/etc/rabbitmq/rabbitmq.conf"
- "./rabbitmq/config/10-default-guest-user.conf:/etc/rabbitmq/conf.d/10-default-guest-user.conf"
- "./rabbitmq/data:/var/lib/rabbitmq"
- "./rabbitmq/plugins/rabbitmq_delayed_message_exchange-3.9.0.ez:/opt/rabbitmq/plugins/rabbitmq_delayed_message_exchange-3.9.0.ez"
# - "./rabbitmq/log:/var/log/rabbitmq"
ports: # 映射端口
- "5672:5672"
- "15672:15672"

@ -0,0 +1,44 @@
#!/bin/bash
####################################
# @description 添加RabbitMQ节点到集群
# 可参考 https://www.rabbitmq.com/clustering.html#creating-ram
# @params $? => 代表上一个命令执行后的退出状态: 0->成功,1->失败
# @example => sh init-rabbitmq.sh
# @author topsuder
# @date 2022/11/16 14:24
####################################
# reset first node
echo "Reset first rabbitmq node."
docker exec rabbitmq-1 /bin/bash -c 'rabbitmqctl stop_app'
docker exec rabbitmq-1 /bin/bash -c 'rabbitmqctl reset'
docker exec rabbitmq-1 /bin/bash -c 'rabbitmqctl start_app'
# build cluster
echo "Starting to build rabbitmq cluster with two ram nodes."
docker exec rabbitmq-2 /bin/bash -c 'rabbitmqctl stop_app'
docker exec rabbitmq-2 /bin/bash -c 'rabbitmqctl reset'
# 参数“--ram”表示设置为内存节点忽略此参数默认为磁盘节点
docker exec rabbitmq-2 /bin/bash -c 'rabbitmqctl join_cluster rabbit@my-rabbit-1'
# docker exec rabbitmq-2 /bin/bash -c 'rabbitmqctl join_cluster --ram rabbit@my-rabbit-1'
docker exec rabbitmq-2 /bin/bash -c 'rabbitmqctl start_app'
# check cluster status
#echo "Check cluster status:"
#docker exec rabbitmq-1 /bin/bash -c 'rabbitmqctl cluster_status'
#docker exec rabbitmq-2 /bin/bash -c 'rabbitmqctl cluster_status'
#echo "Starting to create user."
#docker exec rabbitmq-1 /bin/bash -c 'rabbitmqctl add_user admin admin@123'
#echo "Set tags for new user."
#docker exec rabbitmq-1 /bin/bash -c 'rabbitmqctl set_user_tags admin administrator'
#echo "Grant permissions to new user."
#docker exec rabbitmq-1 /bin/bash -c "rabbitmqctl set_permissions -p '/' admin '.*' '.*' '.*'"

@ -0,0 +1,8 @@
# 环境变量可参考 https://www.rabbitmq.com/configure.html
default_vhost = my_vhost
default_user = admin
default_pass = admin
default_user_tags.administrator = true
default_permissions.configure = .*
default_permissions.read = .*
default_permissions.write = .*

@ -0,0 +1,8 @@
# 环境变量可参考 https://www.rabbitmq.com/configure.html
default_vhost = my_vhost
default_user = admin
default_pass = admin
default_user_tags.administrator = true
default_permissions.configure = .*
default_permissions.read = .*
default_permissions.write = .*

@ -0,0 +1,8 @@
## DEFAULT SETTINGS ARE NOT MEANT TO BE TAKEN STRAIGHT INTO PRODUCTION
## see https://www.rabbitmq.com/configure.html for further information
## on configuring RabbitMQ
## allow access to the guest user from anywhere on the network
## https://www.rabbitmq.com/access-control.html#loopback-users
## https://www.rabbitmq.com/production-checklist.html#users
## loopback_users.guest = false

@ -0,0 +1,8 @@
# 环境变量可参考 https://www.rabbitmq.com/configure.html
default_vhost = my_vhost
default_user = admin
default_pass = admin
default_user_tags.administrator = true
default_permissions.configure = .*
default_permissions.read = .*
default_permissions.write = .*

File diff suppressed because it is too large Load Diff

@ -0,0 +1,925 @@
%% -*- mode: erlang -*-
%% ----------------------------------------------------------------------------
%% Classic RabbitMQ configuration format example.
%% This format should be considered DEPRECATED.
%%
%% Users of RabbitMQ 3.7.x
%% or later should prefer the new style format (rabbitmq.conf)
%% in combination with an advanced.config file (as needed).
%%
%% Related doc guide: https://www.rabbitmq.com/configure.html. See
%% https://rabbitmq.com/documentation.html for documentation ToC.
%% ----------------------------------------------------------------------------
[
{rabbit,
[%%
%% Networking
%% ====================
%%
%% Related doc guide: https://www.rabbitmq.com/networking.html.
%% By default, RabbitMQ will listen on all interfaces, using
%% the standard (reserved) AMQP port.
%%
%% {tcp_listeners, [5672]},
%% To listen on a specific interface, provide a tuple of {IpAddress, Port}.
%% For example, to listen only on localhost for both IPv4 and IPv6:
%%
%% {tcp_listeners, [{"127.0.0.1", 5672},
%% {"::1", 5672}]},
%% TLS listeners are configured in the same fashion as TCP listeners,
%% including the option to control the choice of interface.
%%
%% {ssl_listeners, [5671]},
%% Number of Erlang processes that will accept connections for the TCP
%% and TLS listeners.
%%
%% {num_tcp_acceptors, 10},
%% {num_ssl_acceptors, 1},
%% Maximum time for AMQP 0-8/0-9/0-9-1 handshake (after socket connection
%% and TLS handshake), in milliseconds.
%%
%% {handshake_timeout, 10000},
%% Set to 'true' to perform reverse DNS lookups when accepting a
%% connection. Hostnames will then be shown instead of IP addresses
%% in rabbitmqctl and the management plugin.
%%
%% {reverse_dns_lookups, false},
%%
%% Security, Access Control
%% ========================
%%
%% Related doc guide: https://www.rabbitmq.com/access-control.html.
%% The default "guest" user is only permitted to access the server
%% via a loopback interface (e.g. localhost).
%% {loopback_users, [<<"guest">>]},
%%
%% Uncomment the following line if you want to allow access to the
%% guest user from anywhere on the network.
%% {loopback_users, []},
%% TLS configuration.
%%
%% Related doc guide: https://www.rabbitmq.com/ssl.html.
%%
%% {ssl_options, [{cacertfile, "/path/to/testca/cacert.pem"},
%% {certfile, "/path/to/server/cert.pem"},
%% {keyfile, "/path/to/server/key.pem"},
%% {verify, verify_peer},
%% {fail_if_no_peer_cert, false}]},
%% Choose the available SASL mechanism(s) to expose.
%% The two default (built in) mechanisms are 'PLAIN' and
%% 'AMQPLAIN'. Additional mechanisms can be added via
%% plugins.
%%
%% Related doc guide: https://www.rabbitmq.com/authentication.html.
%%
%% {auth_mechanisms, ['PLAIN', 'AMQPLAIN']},
%% Select an authentication database to use. RabbitMQ comes bundled
%% with a built-in auth-database, based on mnesia.
%%
%% {auth_backends, [rabbit_auth_backend_internal]},
%% Configurations supporting the rabbitmq_auth_mechanism_ssl and
%% rabbitmq_auth_backend_ldap plugins.
%%
%% NB: These options require that the relevant plugin is enabled.
%% Related doc guide: https://www.rabbitmq.com/plugins.html for further details.
%% The RabbitMQ-auth-mechanism-ssl plugin makes it possible to
%% authenticate a user based on the client's TLS certificate.
%%
%% To use auth-mechanism-ssl, add to or replace the auth_mechanisms
%% list with the entry 'EXTERNAL'.
%%
%% {auth_mechanisms, ['EXTERNAL']},
%% The rabbitmq_auth_backend_ldap plugin allows the broker to
%% perform authentication and authorisation by deferring to an
%% external LDAP server.
%%
%% For more information about configuring the LDAP backend, see
%% https://www.rabbitmq.com/ldap.html.
%%
%% Enable the LDAP auth backend by adding to or replacing the
%% auth_backends entry:
%%
%% {auth_backends, [rabbit_auth_backend_ldap]},
%% This pertains to both the rabbitmq_auth_mechanism_ssl plugin and
%% STOMP ssl_cert_login configurations. See the rabbitmq_stomp
%% configuration section later in this file and the README in
%% https://github.com/rabbitmq/rabbitmq-auth-mechanism-ssl for further
%% details.
%%
%% To use the TLS cert's CN instead of its DN as the username
%%
%% {ssl_cert_login_from, distinguished_name},
%% TLS handshake timeout, in milliseconds.
%%
%% {ssl_handshake_timeout, 5000},
%% Makes RabbitMQ accept SSLv3 client connections by default.
%% DO NOT DO THIS IF YOU CAN HELP IT.
%%
%% {ssl_allow_poodle_attack, false},
%% Password hashing implementation. Will only affect newly
%% created users. To recalculate hash for an existing user
%% it's necessary to update her password.
%%
%% When importing definitions exported from versions earlier
%% than 3.6.0, it is possible to go back to MD5 (only do this
%% as a temporary measure!) by setting this to rabbit_password_hashing_md5.
%%
%% To use SHA-512, set to rabbit_password_hashing_sha512.
%%
%% {password_hashing_module, rabbit_password_hashing_sha256},
%% Configuration entry encryption.
%% Related doc guide: https://www.rabbitmq.com/configure.html#configuration-encryption
%%
%% To specify the passphrase in the configuration file:
%%
%% {config_entry_decoder, [{passphrase, <<"mypassphrase">>}]}
%%
%% To specify the passphrase in an external file:
%%
%% {config_entry_decoder, [{passphrase, {file, "/path/to/passphrase/file"}}]}
%%
%% To make the broker request the passphrase when it starts:
%%
%% {config_entry_decoder, [{passphrase, prompt}]}
%%
%% To change encryption settings:
%%
%% {config_entry_decoder, [{cipher, aes_cbc256},
%% {hash, sha512},
%% {iterations, 1000}]}
%%
%% Default User / VHost
%% ====================
%%
%% On first start RabbitMQ will create a vhost and a user. These
%% config items control what gets created. See
%% https://www.rabbitmq.com/access-control.html for further
%% information about vhosts and access control.
%%
%% {default_vhost, <<"/">>},
%% {default_user, <<"guest">>},
%% {default_pass, <<"guest">>},
%% {default_permissions, [<<".*">>, <<".*">>, <<".*">>]},
%% Tags for default user
%%
%% Related doc guide: https://www.rabbitmq.com/management.html.
%%
%% {default_user_tags, [administrator]},
%%
%% Additional network and protocol related configuration
%% =====================================================
%%
%% Sets the default AMQP 0-9-1 heartbeat timeout in seconds.
%% Values lower than 6 can produce false positives and are not
%% recommended.
%%
%% Related doc guides:
%%
%% * https://www.rabbitmq.com/heartbeats.html
%% * https://www.rabbitmq.com/networking.html
%%
%% {heartbeat, 60},
%% Set the max permissible size of an AMQP frame (in bytes).
%%
%% {frame_max, 131072},
%% Set the max frame size the server will accept before connection
%% tuning occurs
%%
%% {initial_frame_max, 4096},
%% Set the max permissible number of channels per connection.
%% 0 means "no limit".
%%
%% {channel_max, 0},
%% Set the max permissible number of client connections to the node.
%% `infinity` means "no limit".
%%
%% This limit applies to client connections to all listeners (regardless of
%% the protocol, whether TLS is used and so on). CLI tools and inter-node
%% connections are exempt.
%%
%% When client connections are rapidly opened in succession, it is possible
%% for the total connection count to go slightly higher than the configured limit.
%% The limit works well as a general safety measure.
%%
%% Clients that are hitting the limit will see their TCP connections fail or time out.
%%
%% Introduced in 3.6.13.
%%
%% Related doc guide: https://www.rabbitmq.com/networking.html.
%%
%% {connection_max, infinity},
%% TCP socket options.
%%
%% Related doc guide: https://www.rabbitmq.com/networking.html.
%%
%% {tcp_listen_options, [{backlog, 128},
%% {nodelay, true},
%% {exit_on_close, false}]},
%%
%% Resource Limits & Flow Control
%% ==============================
%%
%% Related doc guide: https://www.rabbitmq.com/memory.html, https://www.rabbitmq.com/memory-use.html.
%% Memory-based Flow Control threshold.
%%
%% {vm_memory_high_watermark, 0.4},
%% Alternatively, we can set a limit (in bytes) of RAM used by the node.
%%
%% {vm_memory_high_watermark, {absolute, 1073741824}},
%%
%% Or you can set absolute value using memory units (with RabbitMQ 3.6.0+).
%%
%% {vm_memory_high_watermark, {absolute, "1024M"}},
%%
%% Supported unit symbols:
%%
%% k, kiB: kibibytes (2^10 - 1,024 bytes)
%% M, MiB: mebibytes (2^20 - 1,048,576 bytes)
%% G, GiB: gibibytes (2^30 - 1,073,741,824 bytes)
%% kB: kilobytes (10^3 - 1,000 bytes)
%% MB: megabytes (10^6 - 1,000,000 bytes)
%% GB: gigabytes (10^9 - 1,000,000,000 bytes)
%% Fraction of the high watermark limit at which queues start to
%% page message out to disc in order to free up memory.
%% For example, when vm_memory_high_watermark is set to 0.4 and this value is set to 0.5,
%% paging can begin as early as when 20% of total available RAM is used by the node.
%%
%% Values greater than 1.0 can be dangerous and should be used carefully.
%%
%% One alternative to this is to use durable queues and publish messages
%% as persistent (delivery mode = 2). With this combination queues will
%% move messages to disk much more rapidly.
%%
%% Another alternative is to configure queues to page all messages (both
%% persistent and transient) to disk as quickly
%% as possible, see https://www.rabbitmq.com/lazy-queues.html.
%%
%% {vm_memory_high_watermark_paging_ratio, 0.5},
%% Selects Erlang VM memory consumption calculation strategy. Can be `allocated`, `rss` or `legacy` (aliased as `erlang`),
%% Introduced in 3.6.11. `rss` is the default as of 3.6.12.
%% See https://github.com/rabbitmq/rabbitmq-server/issues/1223 and rabbitmq/rabbitmq-common#224 for background.
%% {vm_memory_calculation_strategy, rss},
%% Interval (in milliseconds) at which we perform the check of the memory
%% levels against the watermarks.
%%
%% {memory_monitor_interval, 2500},
%% The total memory available can be calculated from the OS resources
%% - default option - or provided as a configuration parameter:
%% {total_memory_available_override_value, "5000MB"},
%% Set disk free limit (in bytes). Once free disk space reaches this
%% lower bound, a disk alarm will be set - see the documentation
%% listed above for more details.
%%
%% {disk_free_limit, 50000000},
%%
%% Or you can set it using memory units (same as in vm_memory_high_watermark)
%% with RabbitMQ 3.6.0+.
%% {disk_free_limit, "50MB"},
%% {disk_free_limit, "50000kB"},
%% {disk_free_limit, "2GB"},
%% Alternatively, we can set a limit relative to total available RAM.
%%
%% Values lower than 1.0 can be dangerous and should be used carefully.
%% {disk_free_limit, {mem_relative, 2.0}},
%%
%% Clustering
%% =====================
%%
%% Queue master location strategy:
%% * <<"min-masters">>
%% * <<"client-local">>
%% * <<"random">>
%%
%% Related doc guide: https://www.rabbitmq.com/ha.html#queue-master-location
%%
%% {queue_master_locator, <<"client-local">>},
%% Batch size (number of messages) used during eager queue mirror synchronisation.
%% Related doc guide: https://www.rabbitmq.com/ha.html#batch-sync. When average message size is relatively large
%% (say, 10s of kilobytes or greater), reducing this value will decrease peak amount
%% of RAM used by newly joining nodes that need eager synchronisation.
%%
%% {mirroring_sync_batch_size, 4096},
%% Enables flow control between queue mirrors.
%% Disabling this can be dangerous and is not recommended.
%% When flow control is disabled, queue masters can outpace mirrors and not allow mirrors to catch up.
%% Mirrors will end up using increasingly more RAM, eventually triggering a memory alarm.
%%
%% {mirroring_flow_control, true},
%% Additional server properties to announce to connecting clients.
%%
%% {server_properties, []},
%% How to respond to cluster partitions.
%% Related doc guide: https://www.rabbitmq.com/partitions.html
%%
%% {cluster_partition_handling, ignore},
%% Mirror sync batch size, in messages. Increasing this will speed
%% up syncing but total batch size in bytes must not exceed 2 GiB.
%% Available in RabbitMQ 3.6.0 or later.
%%
%% {mirroring_sync_batch_size, 4096},
%% Make clustering happen *automatically* at startup - only applied
%% to nodes that have just been reset or started for the first time.
%% Related doc guide: https://www.rabbitmq.com/clustering.html#auto-config
%%
%% {cluster_nodes, {['rabbit@my.host.com'], disc}},
%% Interval (in milliseconds) at which we send keepalive messages
%% to other cluster members. Note that this is not the same thing
%% as net_ticktime; missed keepalive messages will not cause nodes
%% to be considered down.
%%
%% {cluster_keepalive_interval, 10000},
%%
%% Statistics Collection
%% =====================
%%
%% Set (internal) statistics collection granularity.
%%
%% {collect_statistics, none},
%% Statistics collection interval (in milliseconds). Increasing
%% this will reduce the load on management database.
%%
%% {collect_statistics_interval, 5000},
%% Enables vhosts tracing.
%%
%% {trace_vhosts, []},
%% Explicitly enable/disable HiPE compilation.
%%
%% {hipe_compile, false},
%% Number of delegate processes to use for intra-cluster communication.
%% On a node which is part of cluster, has more than 16 cores and plenty of network bandwidth,
%% it may make sense to increase this value.
%%
%% {delegate_count, 16},
%% Number of times to retry while waiting for internal database tables (Mnesia tables) to sync
%% from a peer. In deployments where nodes can take a long time to boot, this value
%% may need increasing.
%%
%% {mnesia_table_loading_retry_limit, 10},
%% Amount of time in milliseconds which this node will wait for internal database tables (Mnesia tables) to sync
%% from a peer. In deployments where nodes can take a long time to boot, this value
%% may need increasing.
%%
%% {mnesia_table_loading_retry_timeout, 30000},
%% Size in bytes below which to embed messages in the queue index.
%% Related doc guide: https://www.rabbitmq.com/persistence-conf.html
%%
%% {queue_index_embed_msgs_below, 4096},
%% Maximum number of queue index entries to keep in journal
%% Related doc guide: https://www.rabbitmq.com/persistence-conf.html.
%%
%% {queue_index_max_journal_entries, 32768},
%% Number of credits that a queue process is given by the message store
%% By default, a queue process is given 4000 message store credits,
%% and then 800 for every 800 messages that it processes.
%%
%% {msg_store_credit_disc_bound, {4000, 800}},
%% Minimum number of messages with their queue position held in RAM required
%% to trigger writing their queue position to disk.
%%
%% This value MUST be higher than the initial msg_store_credit_disc_bound value,
%% otherwise paging performance may worsen.
%%
%% {msg_store_io_batch_size, 4096},
%% Number of credits that a connection, channel or queue are given.
%%
%% By default, every connection, channel or queue is given 400 credits,
%% and then 200 for every 200 messages that it sends to a peer process.
%% Increasing these values may help with throughput but also can be dangerous:
%% high credit flow values are no different from not having flow control at all.
%%
%% Related doc guide: https://www.rabbitmq.com/blog/2015/10/06/new-credit-flow-settings-on-rabbitmq-3-5-5/
%% and http://alvaro-videla.com/2013/09/rabbitmq-internals-credit-flow-for-erlang-processes.html.
%%
%% {credit_flow_default_credit, {400, 200}},
%% Number of milliseconds before a channel operation times out.
%%
%% {channel_operation_timeout, 15000},
%% Number of queue operations required to trigger an explicit garbage collection.
%% Increasing this value may reduce CPU load and increase peak RAM consumption of queues.
%%
%% {queue_explicit_gc_run_operation_threshold, 1000},
%% Number of lazy queue operations required to trigger an explicit garbage collection.
%% Increasing this value may reduce CPU load and increase peak RAM consumption of lazy queues.
%%
%% {lazy_queue_explicit_gc_run_operation_threshold, 1000},
%% Number of times disk monitor will retry free disk space queries before
%% giving up.
%%
%% {disk_monitor_failure_retries, 10},
%% Milliseconds to wait between disk monitor retries on failures.
%%
%% {disk_monitor_failure_retry_interval, 120000},
%% Whether or not to enable background periodic forced GC runs for all
%% Erlang processes on the node in "waiting" state.
%%
%% Disabling background GC may reduce latency for client operations,
%% keeping it enabled may reduce median RAM usage by the binary heap
%% (see https://www.erlang-solutions.com/blog/erlang-garbage-collector.html).
%%
%% Before enabling this option, please take a look at the memory
%% breakdown (https://www.rabbitmq.com/memory-use.html).
%%
%% {background_gc_enabled, false},
%% Interval (in milliseconds) at which we run background GC.
%%
%% {background_gc_target_interval, 60000},
%% Message store operations are stored in a sequence of files called segments.
%% This controls max size of a segment file.
%% Increasing this value may speed up (sequential) disk writes but will slow down segment GC process.
%% DO NOT CHANGE THIS for existing installations.
%%
%% {msg_store_file_size_limit, 16777216},
%% Whether or not to enable file write buffering.
%%
%% {fhc_write_buffering, true},
%% Whether or not to enable file read buffering. Enabling
%% this may slightly speed up reads but will also increase
%% node's memory consumption, in particular on boot.
%%
%% {fhc_read_buffering, false}
]},
%% ----------------------------------------------------------------------------
%% Advanced Erlang Networking/Clustering Options.
%%
%% Related doc guide: https://www.rabbitmq.com/clustering.html
%% ----------------------------------------------------------------------------
{kernel,
[%% Sets the net_kernel tick time.
%% Please see http://erlang.org/doc/man/kernel_app.html and
%% https://www.rabbitmq.com/nettick.html for further details.
%%
%% {net_ticktime, 60}
]},
%% ----------------------------------------------------------------------------
%% RabbitMQ Management Plugin
%%
%% Related doc guide: https://www.rabbitmq.com/management.html
%% ----------------------------------------------------------------------------
{rabbitmq_management,
[%% Preload schema definitions from a previously exported definitions file. See
%% https://www.rabbitmq.com/management.html#load-definitions
%%
%% {load_definitions, "/path/to/exported/definitions.json"},
%% Log all requests to the management HTTP API to a directory.
%%
%% {http_log_dir, "/path/to/rabbitmq/logs/http"},
%% Change the port on which the HTTP listener listens,
%% specifying an interface for the web server to bind to.
%% Also set the listener to use TLS and provide TLS options.
%%
%% {listener, [{port, 12345},
%% {ip, "127.0.0.1"},
%% {ssl, true},
%% {ssl_opts, [{cacertfile, "/path/to/cacert.pem"},
%% {certfile, "/path/to/cert.pem"},
%% {keyfile, "/path/to/key.pem"}]}]},
%% One of 'basic', 'detailed' or 'none'. See
%% https://www.rabbitmq.com/management.html#fine-stats for more details.
%% {rates_mode, basic},
%% Configure how long aggregated data (such as message rates and queue
%% lengths) is retained. Please read the plugin's documentation in
%% https://www.rabbitmq.com/management.html#configuration for more
%% details.
%%
%% {sample_retention_policies,
%% [{global, [{60, 5}, {3600, 60}, {86400, 1200}]},
%% {basic, [{60, 5}, {3600, 60}]},
%% {detailed, [{10, 5}]}]}
]},
%% ----------------------------------------------------------------------------
%% RabbitMQ Shovel Plugin
%%
%% Related doc guide: https://www.rabbitmq.com/shovel.html
%% ----------------------------------------------------------------------------
{rabbitmq_shovel,
[{shovels,
[%% A named shovel worker.
%% {my_first_shovel,
%% [
%% List the source broker(s) from which to consume.
%%
%% {sources,
%% [%% URI(s) and pre-declarations for all source broker(s).
%% {brokers, ["amqp://user:password@host.domain/my_vhost"]},
%% {declarations, []}
%% ]},
%% List the destination broker(s) to publish to.
%% {destinations,
%% [%% A singular version of the 'brokers' element.
%% {broker, "amqp://"},
%% {declarations, []}
%% ]},
%% Name of the queue to shovel messages from.
%%
%% {queue, <<"your-queue-name-goes-here">>},
%% Optional prefetch count.
%%
%% {prefetch_count, 10},
%% when to acknowledge messages:
%% - no_ack: never (auto)
%% - on_publish: after each message is republished
%% - on_confirm: when the destination broker confirms receipt
%%
%% {ack_mode, on_confirm},
%% Overwrite fields of the outbound basic.publish.
%%
%% {publish_fields, [{exchange, <<"my_exchange">>},
%% {routing_key, <<"from_shovel">>}]},
%% Static list of basic.properties to set on re-publication.
%%
%% {publish_properties, [{delivery_mode, 2}]},
%% The number of seconds to wait before attempting to
%% reconnect in the event of a connection failure.
%%
%% {reconnect_delay, 2.5}
%% ]} %% End of my_first_shovel
]}
%% Rather than specifying some values per-shovel, you can specify
%% them for all shovels here.
%%
%% {defaults, [{prefetch_count, 0},
%% {ack_mode, on_confirm},
%% {publish_fields, []},
%% {publish_properties, [{delivery_mode, 2}]},
%% {reconnect_delay, 2.5}]}
]},
%% ----------------------------------------------------------------------------
%% RabbitMQ STOMP Plugin
%%
%% Related doc guide: https://www.rabbitmq.com/stomp.html
%% ----------------------------------------------------------------------------
{rabbitmq_stomp,
[%% Network Configuration - the format is generally the same as for the broker
%% Listen only on localhost (ipv4 & ipv6) on a specific port.
%% {tcp_listeners, [{"127.0.0.1", 61613},
%% {"::1", 61613}]},
%% Listen for TLS connections on a specific port.
%% {ssl_listeners, [61614]},
%% Number of Erlang processes that will accept connections for the TCP
%% and TLS listeners.
%%
%% {num_tcp_acceptors, 10},
%% {num_ssl_acceptors, 1},
%% Additional TLS options
%% Extract a name from the client's certificate when using TLS.
%%
%% {ssl_cert_login, true},
%% Set a default user name and password. This is used as the default login
%% whenever a CONNECT frame omits the login and passcode headers.
%%
%% Please note that setting this will allow clients to connect without
%% authenticating!
%%
%% {default_user, [{login, "guest"},
%% {passcode, "guest"}]},
%% If a default user is configured, or you have configured use TLS client
%% certificate based authentication, you can choose to allow clients to
%% omit the CONNECT frame entirely. If set to true, the client is
%% automatically connected as the default user or user supplied in the
%% TLS certificate whenever the first frame sent on a session is not a
%% CONNECT frame.
%%
%% {implicit_connect, true},
%% Whether or not to enable proxy protocol support.
%% Once enabled, clients cannot directly connect to the broker
%% anymore. They must connect through a load balancer that sends the
%% proxy protocol header to the broker at connection time.
%% This setting applies only to STOMP clients, other protocols
%% like MQTT or AMQP have their own setting to enable proxy protocol.
%% See the plugins or broker documentation for more information.
%%
%% {proxy_protocol, false}
]},
%% ----------------------------------------------------------------------------
%% RabbitMQ MQTT Plugin
%%
%% Related doc guide: https://github.com/rabbitmq/rabbitmq-mqtt/blob/stable/README.md
%%
%% ----------------------------------------------------------------------------
{rabbitmq_mqtt,
[%% Set the default user name and password. Will be used as the default login
%% if a connecting client provides no other login details.
%%
%% Please note that setting this will allow clients to connect without
%% authenticating!
%%
%% {default_user, <<"guest">>},
%% {default_pass, <<"guest">>},
%% Enable anonymous access. If this is set to false, clients MUST provide
%% login information in order to connect. See the default_user/default_pass
%% configuration elements for managing logins without authentication.
%%
%% {allow_anonymous, true},
%% If you have multiple chosts, specify the one to which the
%% adapter connects.
%%
%% {vhost, <<"/">>},
%% Specify the exchange to which messages from MQTT clients are published.
%%
%% {exchange, <<"amq.topic">>},
%% Specify TTL (time to live) to control the lifetime of non-clean sessions.
%%
%% {subscription_ttl, 1800000},
%% Set the prefetch count (governing the maximum number of unacknowledged
%% messages that will be delivered).
%%
%% {prefetch, 10},
%% TLS listeners.
%% See https://www.rabbitmq.com/networking.html
%%
%% {tcp_listeners, [1883]},
%% {ssl_listeners, []},
%% Number of Erlang processes that will accept connections for the TCP
%% and TLS listeners.
%% See https://www.rabbitmq.com/networking.html
%%
%% {num_tcp_acceptors, 10},
%% {num_ssl_acceptors, 1},
%% TCP socket options.
%% See https://www.rabbitmq.com/networking.html
%%
%% {tcp_listen_options, [
%% {backlog, 128},
%% {linger, {true, 0}},
%% {exit_on_close, false}
%% ]},
%% Whether or not to enable proxy protocol support.
%% Once enabled, clients cannot directly connect to the broker
%% anymore. They must connect through a load balancer that sends the
%% proxy protocol header to the broker at connection time.
%% This setting applies only to MQTT clients, other protocols
%% like STOMP or AMQP have their own setting to enable proxy protocol.
%% See the plugins or broker documentation for more information.
%%
%% {proxy_protocol, false}
]},
%% ----------------------------------------------------------------------------
%% RabbitMQ AMQP 1.0 Support
%%
%% Related doc guide: https://github.com/rabbitmq/rabbitmq-amqp1.0/blob/stable/README.md
%%
%% ----------------------------------------------------------------------------
{rabbitmq_amqp1_0,
[%% Connections that are not authenticated with SASL will connect as this
%% account. See the README for more information.
%%
%% Please note that setting this will allow clients to connect without
%% authenticating!
%%
%% {default_user, "guest"},
%% Enable protocol strict mode. See the README for more information.
%%
%% {protocol_strict_mode, false}
]},
%% ----------------------------------------------------------------------------
%% RabbitMQ LDAP Plugin
%%
%% Related doc guide: https://www.rabbitmq.com/ldap.html.
%%
%% ----------------------------------------------------------------------------
{rabbitmq_auth_backend_ldap,
[%%
%% Connecting to the LDAP server(s)
%% ================================
%%
%% Specify servers to bind to. You *must* set this in order for the plugin
%% to work properly.
%%
%% {servers, ["your-server-name-goes-here"]},
%% Connect to the LDAP server using TLS
%%
%% {use_ssl, false},
%% Specify the LDAP port to connect to
%%
%% {port, 389},
%% LDAP connection timeout, in milliseconds or 'infinity'
%%
%% {timeout, infinity},
%% Enable logging of LDAP queries.
%% One of
%% - false (no logging is performed)
%% - true (verbose logging of the logic used by the plugin)
%% - network (as true, but additionally logs LDAP network traffic)
%%
%% Defaults to false.
%%
%% {log, false},
%%
%% Authentication
%% ==============
%%
%% Pattern to convert the username given through AMQP to a DN before
%% binding
%%
%% {user_dn_pattern, "cn=${username},ou=People,dc=example,dc=com"},
%% Alternatively, you can convert a username to a Distinguished
%% Name via an LDAP lookup after binding. See the documentation for
%% full details.
%% When converting a username to a dn via a lookup, set these to
%% the name of the attribute that represents the user name, and the
%% base DN for the lookup query.
%%
%% {dn_lookup_attribute, "userPrincipalName"},
%% {dn_lookup_base, "DC=gopivotal,DC=com"},
%% Controls how to bind for authorisation queries and also to
%% retrieve the details of users logging in without presenting a
%% password (e.g., SASL EXTERNAL).
%% One of
%% - as_user (to bind as the authenticated user - requires a password)
%% - anon (to bind anonymously)
%% - {UserDN, Password} (to bind with a specified user name and password)
%%
%% Defaults to 'as_user'.
%%
%% {other_bind, as_user},
%%
%% Authorisation
%% =============
%%
%% The LDAP plugin can perform a variety of queries against your
%% LDAP server to determine questions of authorisation. See
%% https://www.rabbitmq.com/ldap.html#authorisation for more
%% information.
%% Set the query to use when determining vhost access
%%
%% {vhost_access_query, {in_group,
%% "ou=${vhost}-users,ou=vhosts,dc=example,dc=com"}},
%% Set the query to use when determining resource (e.g., queue) access
%%
%% {resource_access_query, {constant, true}},
%% Set queries to determine which tags a user has
%%
%% {tag_queries, []}
]},
%% Lager controls logging.
%% See https://github.com/basho/lager for more documentation
{lager, [
%%
%% Log directory, taken from the RABBITMQ_LOG_BASE env variable by default.
%% {log_root, "/var/log/rabbitmq"},
%%
%% All log messages go to the default "sink" configured with
%% the `handlers` parameter. By default, it has a single
%% lager_file_backend handler writing messages to "$nodename.log"
%% (ie. the value of $RABBIT_LOGS).
%% {handlers, [
%% {lager_file_backend, [{file, "rabbit.log"},
%% {level, info},
%% {date, ""},
%% {size, 0}]}
%% ]},
%%
%% Extra sinks are used in RabbitMQ to categorize messages. By
%% default, those extra sinks are configured to forward messages
%% to the default sink (see above). "rabbit_log_lager_event"
%% is the default category where all RabbitMQ messages without
%% a category go. Messages in the "channel" category go to the
%% "rabbit_channel_lager_event" Lager extra sink, and so on.
%% {extra_sinks, [
%% {rabbit_log_lager_event, [{handlers, [
%% {lager_forwarder_backend,
%% [lager_event, info]}]}]},
%% {rabbit_channel_lager_event, [{handlers, [
%% {lager_forwarder_backend,
%% [lager_event, info]}]}]},
%% {rabbit_connection_lager_event, [{handlers, [
%% {lager_forwarder_backend,
%% [lager_event, info]}]}]},
%% {rabbit_mirroring_lager_event, [{handlers, [
%% {lager_forwarder_backend,
%% [lager_event, info]}]}]}
%% ]}
]}
].

@ -0,0 +1,59 @@
version: '3.5'
services:
# mq服务
rocketmq_server:
image: foxiswho/rocketmq:server
container_name: rocketmq_server
ports:
- 9876:9876
volumes:
- ./rocketmq/rocketmq_server/logs:/opt/logs
- ./rocketmq/rocketmq_server/store:/opt/store
networks:
rocketmq:
aliases:
- rocketmq_server
# mq中间件
rocketmq_broker:
image: foxiswho/rocketmq:broker
container_name: rocketmq_broker
ports:
- 10909:10909
- 10911:10911
volumes:
- ./rocketmq/rocketmq_broker/logs:/opt/logs
- ./rocketmq/rocketmq_broker/store:/opt/store
- ./rocketmq/rocketmq_broker/conf/broker.conf:/etc/rocketmq/broker.conf
environment:
NAMESRV_ADDR: "rocketmq_server:9876"
JAVA_OPTS: " -Duser.home=/opt"
JAVA_OPT_EXT: "-server -Xms128m -Xmx128m -Xmn128m"
command: mqbroker -c /etc/rocketmq/broker.conf
depends_on:
- rocketmq_server
networks:
rocketmq:
aliases:
- rocketmq_broker
# mq可视化控制台
rocketmq_console_ng:
image: styletang/rocketmq-console-ng
container_name: rocketmq_console_ng
ports:
- 9002:8080
environment:
JAVA_OPTS: "-Drocketmq.namesrv.addr=rocketmq_server:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false"
depends_on:
- rocketmq_server
networks:
rocketmq:
aliases:
- rocketmq_console_ng
#容器通信network
networks:
rocketmq:
name: rocketmq
driver: bridge

@ -0,0 +1,96 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# 所属集群名字
brokerClusterName=DefaultCluster
# broker 名字,注意此处不同的配置文件填写的不一样,如果在 broker-a.properties 使用: broker-a,
# 在 broker-b.properties 使用: broker-b
brokerName=broker-a
# 0 表示 Master> 0 表示 Slave
brokerId=0
# nameServer地址分号分割
# namesrvAddr=rocketmq-nameserver1:9876;rocketmq-nameserver2:9876
# 启动IP,如果 docker 报 com.alibaba.rocketmq.remoting.exception.RemotingConnectException: connect to <192.168.0.88:10909> failed
# 解决方式1 加上一句 producer.setVipChannelEnabled(false);解决方式2 brokerIP1 设置宿主机IP不要使用docker 内部IP
# brokerIP1=192.168.0.88
# 在发送消息时自动创建服务器不存在的topic默认创建的队列数
defaultTopicQueueNums=4
# 是否允许 Broker 自动创建 Topic建议线下开启线上关闭 !!!这里仔细看是 falsefalsefalse
autoCreateTopicEnable=true
# 是否允许 Broker 自动创建订阅组,建议线下开启,线上关闭
autoCreateSubscriptionGroup=true
# Broker 对外服务的监听端口
listenPort=10911
# 删除文件时间点默认凌晨4点
deleteWhen=04
# 文件保留时间默认48小时
fileReservedTime=120
# commitLog 每个文件的大小默认1G
mapedFileSizeCommitLog=1073741824
# ConsumeQueue 每个文件默认存 30W 条,根据业务情况调整
mapedFileSizeConsumeQueue=300000
# destroyMapedFileIntervalForcibly=120000
# redeleteHangedFileInterval=120000
# 检测物理文件磁盘空间
diskMaxUsedSpaceRatio=88
# 存储路径
# storePathRootDir=/home/ztztdata/rocketmq-all-4.1.0-incubating/store
# commitLog 存储路径
# storePathCommitLog=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/commitlog
# 消费队列存储
# storePathConsumeQueue=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/consumequeue
# 消息索引存储路径
# storePathIndex=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/index
# checkpoint 文件存储路径
# storeCheckpoint=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/checkpoint
# abort 文件存储路径
# abortFile=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/abort
# 限制的消息大小
maxMessageSize=65536
# flushCommitLogLeastPages=4
# flushConsumeQueueLeastPages=2
# flushCommitLogThoroughInterval=10000
# flushConsumeQueueThoroughInterval=60000
# Broker 的角色
# - ASYNC_MASTER 异步复制Master
# - SYNC_MASTER 同步双写Master
# - SLAVE
brokerRole=ASYNC_MASTER
# 刷盘方式
# - ASYNC_FLUSH 异步刷盘
# - SYNC_FLUSH 同步刷盘
flushDiskType=ASYNC_FLUSH
# 发消息线程池数量
# sendMessageThreadPoolNums=128
# 拉消息线程池数量
# pullMessageThreadPoolNums=128

@ -196,6 +196,13 @@
<version>${weixin-java}</version> <version>${weixin-java}</version>
</dependency> </dependency>
<!-- 支付宝sdk https://mvnrepository.com/artifact/com.alipay.sdk/alipay-sdk-java -->
<dependency>
<groupId>com.alipay.sdk</groupId>
<artifactId>alipay-sdk-java</artifactId>
<version>4.33.39.ALL</version>
</dependency>
<!--阿里云 钉钉 SDK--> <!--阿里云 钉钉 SDK-->
<dependency> <dependency>
<groupId>com.aliyun</groupId> <groupId>com.aliyun</groupId>

Loading…
Cancel
Save