mirror of https://github.com/ZhongFuCheng3y/austin
2. 打印austin banner 3. docker-compose.yml 增加mysql配置 4. graylog 只在test环境打印 5. 部分常量抽取pull/57/head
parent
6f7ed66121
commit
86bf561e77
@ -0,0 +1,39 @@
|
||||
package com.java3y.austin.common.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 撤回任务信息
|
||||
*
|
||||
* @author 3y
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class RecallTaskInfo {
|
||||
/**
|
||||
* 消息模板Id
|
||||
*/
|
||||
private Long messageTemplateId;
|
||||
|
||||
/**
|
||||
* 需要撤回的消息ids
|
||||
*/
|
||||
private List<String> recallMessageId;
|
||||
|
||||
/**
|
||||
* 发送账号
|
||||
*/
|
||||
private Integer sendAccount;
|
||||
|
||||
/**
|
||||
* 发送渠道
|
||||
*/
|
||||
private Integer sendChannel;
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package com.java3y.austin.service.api.impl.action.recall;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import com.java3y.austin.common.constant.CommonConstant;
|
||||
import com.java3y.austin.common.domain.RecallTaskInfo;
|
||||
import com.java3y.austin.common.enums.RespStatusEnum;
|
||||
import com.java3y.austin.common.vo.BasicResultVO;
|
||||
import com.java3y.austin.service.api.impl.domain.RecallTaskModel;
|
||||
import com.java3y.austin.support.dao.MessageTemplateDao;
|
||||
import com.java3y.austin.support.domain.MessageTemplate;
|
||||
import com.java3y.austin.support.pipeline.BusinessProcess;
|
||||
import com.java3y.austin.support.pipeline.ProcessContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author 3y
|
||||
* 组装撤回参数
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class RecallAssembleAction implements BusinessProcess<RecallTaskModel> {
|
||||
|
||||
@Autowired
|
||||
private MessageTemplateDao messageTemplateDao;
|
||||
|
||||
@Override
|
||||
public void process(ProcessContext<RecallTaskModel> context) {
|
||||
RecallTaskModel recallTaskModel = context.getProcessModel();
|
||||
Long messageTemplateId = recallTaskModel.getMessageTemplateId();
|
||||
try {
|
||||
Optional<MessageTemplate> messageTemplate = messageTemplateDao.findById(messageTemplateId);
|
||||
if (!messageTemplate.isPresent() || messageTemplate.get().getIsDeleted().equals(CommonConstant.TRUE)) {
|
||||
context.setNeedBreak(true).setResponse(BasicResultVO.fail(RespStatusEnum.TEMPLATE_NOT_FOUND));
|
||||
return;
|
||||
}
|
||||
|
||||
RecallTaskInfo recallTaskInfo = RecallTaskInfo.builder().messageTemplateId(messageTemplateId)
|
||||
.recallMessageId(recallTaskModel.getRecallMessageId())
|
||||
.sendAccount(messageTemplate.get().getSendAccount())
|
||||
.sendChannel(messageTemplate.get().getSendChannel())
|
||||
.build();
|
||||
recallTaskModel.setRecallTaskInfo(recallTaskInfo);
|
||||
|
||||
} catch (Exception e) {
|
||||
context.setNeedBreak(true).setResponse(BasicResultVO.fail(RespStatusEnum.SERVICE_ERROR));
|
||||
log.error("assemble recall task fail! templateId:{}, e:{}", messageTemplateId, Throwables.getStackTraceAsString(e));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package com.java3y.austin.service.api.impl.action.recall;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.java3y.austin.common.domain.RecallTaskInfo;
|
||||
import com.java3y.austin.common.enums.RespStatusEnum;
|
||||
import com.java3y.austin.common.vo.BasicResultVO;
|
||||
import com.java3y.austin.service.api.impl.domain.RecallTaskModel;
|
||||
import com.java3y.austin.support.mq.SendMqService;
|
||||
import com.java3y.austin.support.pipeline.BusinessProcess;
|
||||
import com.java3y.austin.support.pipeline.ProcessContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author 3y
|
||||
* 将撤回消息发送到MQ
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class RecallMqAction implements BusinessProcess<RecallTaskModel> {
|
||||
@Autowired
|
||||
private SendMqService sendMqService;
|
||||
|
||||
@Value("${austin.business.recall.topic.name}")
|
||||
private String austinRecall;
|
||||
@Value("${austin.business.tagId.value}")
|
||||
private String tagId;
|
||||
|
||||
@Value("${austin.mq.pipeline}")
|
||||
private String mqPipeline;
|
||||
|
||||
@Override
|
||||
public void process(ProcessContext<RecallTaskModel> context) {
|
||||
RecallTaskInfo recallTaskInfo = context.getProcessModel().getRecallTaskInfo();
|
||||
try {
|
||||
String message = JSON.toJSONString(recallTaskInfo, new SerializerFeature[]{SerializerFeature.WriteClassName});
|
||||
sendMqService.send(austinRecall, message, tagId);
|
||||
} catch (Exception e) {
|
||||
context.setNeedBreak(true).setResponse(BasicResultVO.fail(RespStatusEnum.SERVICE_ERROR));
|
||||
log.error("send {} fail! e:{},params:{}", mqPipeline, Throwables.getStackTraceAsString(e)
|
||||
, JSON.toJSONString(recallTaskInfo));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package com.java3y.austin.service.api.impl.domain;
|
||||
|
||||
import com.java3y.austin.common.domain.RecallTaskInfo;
|
||||
import com.java3y.austin.support.pipeline.ProcessModel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 3y
|
||||
* @date 2021/11/22
|
||||
* @description 发送消息任务模型
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
public class RecallTaskModel implements ProcessModel {
|
||||
|
||||
/**
|
||||
* 消息模板Id
|
||||
*/
|
||||
private Long messageTemplateId;
|
||||
|
||||
/**
|
||||
* 需要撤回的消息ids
|
||||
*/
|
||||
private List<String> recallMessageId;
|
||||
|
||||
/**
|
||||
* 撤回任务 domain
|
||||
*/
|
||||
private RecallTaskInfo recallTaskInfo;
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
[mysqld]
|
||||
max_connections=10000
|
||||
group_concat_max_len=10240
|
||||
wait_timeout=300
|
||||
interactive_timeout=500
|
Loading…
Reference in new issue