diff --git a/INSTALL.md b/INSTALL.md index d4e6039..540bc97 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -193,8 +193,10 @@ docker exec -it kafka sh $KAFKA_HOME/bin/kafka-topics.sh --create --topic austinBusiness --partitions 1 --zookeeper zookeeper:2181 --replication-factor 1 +$KAFKA_HOME/bin/kafka-topics.sh --create --topic austinLog --partitions 1 --zookeeper zookeeper:2181 --replication-factor 1 -$KAFKA_HOME/bin/kafka-topics.sh --create --topic austinLog --partitions 1 --zookeeper zookeeper:2181 --replication-factor 1 +$KAFKA_HOME/bin/kafka-topics.sh --create --topic austinRecall --partitions 1 --zookeeper zookeeper:2181 --replication-factor 1 + ``` 查看刚创建的topic信息: @@ -284,8 +286,13 @@ PS:我的namespace是`boss.austin` ![](https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/4c4636a5620a454b931aea8b248e2890~tplv-k3u1fbpfcp-watermark.image?) +apollo配置样例可看example/apollo.properties文件的内容 + `dynamic-tp-apollo-dtp`它是一个apollo的namespace,存放着动态线程池的配置 +动态线程池样例配置可看 dynamic-tp-apollo-dtp.yml 文件的内容 + + ## 06、安装PROMETHEUS和GRAFANA(可选) 存放`docker-compose.yml`的信息: diff --git a/austin-common/src/main/java/com/java3y/austin/common/dto/model/EnterpriseWeChatContentModel.java b/austin-common/src/main/java/com/java3y/austin/common/dto/model/EnterpriseWeChatContentModel.java index 2ff2209..a78cc86 100644 --- a/austin-common/src/main/java/com/java3y/austin/common/dto/model/EnterpriseWeChatContentModel.java +++ b/austin-common/src/main/java/com/java3y/austin/common/dto/model/EnterpriseWeChatContentModel.java @@ -5,6 +5,8 @@ import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import java.util.Map; + /** * @author 3y * 企业微信 应用消息 @@ -21,7 +23,7 @@ public class EnterpriseWeChatContentModel extends ContentModel { private String sendType; /** - * 文本消息 - 文案 + * 文案 */ private String content; @@ -30,9 +32,54 @@ public class EnterpriseWeChatContentModel extends ContentModel { */ private String mediaId; + /** + * 标题 + */ + private String title; + + /** + * 描述 + */ + private String description; + + /** + * 链接 + */ + private String url; + + /** + * 按钮文案 + */ + private String btnTxt; + + /** + * 图文消息 + * [{"title":"中秋节礼品领取","description":"今年中秋节公司有豪礼相送","url":"URL","picurl":"http://res.mail.qq.com/node/ww/wwopenmng/images/independent/doc/test_pic_msg1.png","appid":"wx123123123123123","pagepath":"pages/index?userid=zhangsan&orderid=123123123"}] + */ + private String articles; + + /** + * 图文消息(mpnews) + * [{"title":"Title","thumb_media_id":"MEDIA_ID","author":"Author","content_source_url":"URL","content":"Content","digest":"Digest description"}] + */ + private String mpNewsArticle; + + + /** + * 小程序 + */ + private String appId; + private String page; + private Boolean emphasisFirstItem; + private String contentItems; + + + /** * 其他消息类型: https://developer.work.weixin.qq.com/document/path/90372#%E6%96%87%E6%9C%AC%E6%B6%88%E6%81%AF */ + + } diff --git a/austin-common/src/main/java/com/java3y/austin/common/enums/SendMessageType.java b/austin-common/src/main/java/com/java3y/austin/common/enums/SendMessageType.java index 791bbda..47c939f 100644 --- a/austin-common/src/main/java/com/java3y/austin/common/enums/SendMessageType.java +++ b/austin-common/src/main/java/com/java3y/austin/common/enums/SendMessageType.java @@ -27,6 +27,8 @@ public enum SendMessageType { LINK("110", "链接消息", "link", "link"), ACTION_CARD("120", "跳转卡片消息", "actionCard", "action_card"), OA("130", "OA消息", null, "oa"), + MP_NEWS("140", "图文消息(mpnews)", null, null), + ; private String code; diff --git a/austin-handler/src/main/java/com/java3y/austin/handler/handler/impl/EnterpriseWeChatHandler.java b/austin-handler/src/main/java/com/java3y/austin/handler/handler/impl/EnterpriseWeChatHandler.java index 395fa2e..15d34e6 100644 --- a/austin-handler/src/main/java/com/java3y/austin/handler/handler/impl/EnterpriseWeChatHandler.java +++ b/austin-handler/src/main/java/com/java3y/austin/handler/handler/impl/EnterpriseWeChatHandler.java @@ -8,6 +8,7 @@ import com.java3y.austin.common.constant.SendAccountConstant; import com.java3y.austin.common.domain.TaskInfo; import com.java3y.austin.common.dto.model.EnterpriseWeChatContentModel; import com.java3y.austin.common.enums.ChannelType; +import com.java3y.austin.common.enums.SendMessageType; import com.java3y.austin.handler.handler.BaseHandler; import com.java3y.austin.handler.handler.Handler; import com.java3y.austin.support.domain.MessageTemplate; @@ -17,6 +18,8 @@ import me.chanjar.weixin.common.error.WxMpErrorMsgEnum; import me.chanjar.weixin.cp.api.WxCpService; import me.chanjar.weixin.cp.api.impl.WxCpMessageServiceImpl; import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl; +import me.chanjar.weixin.cp.bean.article.MpnewsArticle; +import me.chanjar.weixin.cp.bean.article.NewArticle; import me.chanjar.weixin.cp.bean.message.WxCpMessage; import me.chanjar.weixin.cp.bean.message.WxCpMessageSendResult; import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl; @@ -24,6 +27,9 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import java.util.List; +import java.util.Map; + /** * @author 3y * 企业微信推送处理 @@ -63,7 +69,6 @@ public class EnterpriseWeChatHandler extends BaseHandler implements Handler { } - /** * 初始化 WxCpServiceImpl 服务接口 * @@ -90,14 +95,42 @@ public class EnterpriseWeChatHandler extends BaseHandler implements Handler { } else { userId = StringUtils.join(taskInfo.getReceiver(), DELIMITER); } - EnterpriseWeChatContentModel enterpriseWeChatContentModel = (EnterpriseWeChatContentModel) taskInfo.getContentModel(); - return WxCpMessage - .TEXT() - .agentId(agentId) - .toUser(userId) - .content(enterpriseWeChatContentModel.getContent()) - .build(); + EnterpriseWeChatContentModel contentModel = (EnterpriseWeChatContentModel) taskInfo.getContentModel(); + + // 通用配置 + WxCpMessage wxCpMessage = null; + + if (SendMessageType.TEXT.getCode().equals(contentModel.getSendType())) { + wxCpMessage = WxCpMessage.TEXT().content(contentModel.getContent()).build(); + } else if (SendMessageType.IMAGE.getCode().equals(contentModel.getSendType())) { + wxCpMessage = WxCpMessage.IMAGE().mediaId(contentModel.getMediaId()).build(); + } else if (SendMessageType.VOICE.getCode().equals(contentModel.getSendType())) { + wxCpMessage = WxCpMessage.VOICE().mediaId(contentModel.getMediaId()).build(); + } else if (SendMessageType.VIDEO.getCode().equals(contentModel.getSendType())) { + wxCpMessage = WxCpMessage.VIDEO().mediaId(contentModel.getMediaId()).description(contentModel.getDescription()).title(contentModel.getTitle()).build(); + } else if (SendMessageType.FILE.getCode().equals(contentModel.getSendType())) { + wxCpMessage = WxCpMessage.FILE().mediaId(contentModel.getMediaId()).build(); + } else if (SendMessageType.TEXT_CARD.getCode().equals(contentModel.getSendType())) { + wxCpMessage = WxCpMessage.TEXTCARD().url(contentModel.getUrl()).title(contentModel.getTitle()).description(contentModel.getDescription()).btnTxt(contentModel.getBtnTxt()).build(); + } else if (SendMessageType.NEWS.getCode().equals(contentModel.getSendType())) { + List newArticles = JSON.parseArray(contentModel.getArticles(), NewArticle.class); + wxCpMessage = WxCpMessage.NEWS().articles(newArticles).build(); + } else if (SendMessageType.MP_NEWS.getCode().equals(contentModel.getSendType())) { + List mpNewsArticles = JSON.parseArray(contentModel.getMpNewsArticle(), MpnewsArticle.class); + wxCpMessage = WxCpMessage.MPNEWS().articles(mpNewsArticles).build(); + } else if (SendMessageType.MARKDOWN.getCode().equals(contentModel.getSendType())) { + wxCpMessage = WxCpMessage.MARKDOWN().content(contentModel.getContent()).build(); + } else if (SendMessageType.MINI_PROGRAM_NOTICE.getCode().equals(contentModel.getSendType())) { + Map contentItems = JSON.parseObject(contentModel.getContentItems(), Map.class); + wxCpMessage = WxCpMessage.newMiniProgramNoticeBuilder().appId(contentModel.getAppId()).page(contentModel.getPage()).emphasisFirstItem(contentModel.getEmphasisFirstItem()).contentItems(contentItems).title(contentModel.getTitle()).description(contentModel.getDescription()).build(); + } else if (SendMessageType.TEMPLATE_CARD.getCode().equals(contentModel.getSendType())) { + // WxJava 未支持 + } + wxCpMessage.setAgentId(agentId); + wxCpMessage.setToUser(userId); + return wxCpMessage; } + @Override public void recall(MessageTemplate messageTemplate) { diff --git a/austin-service-api-impl/src/main/java/com/java3y/austin/service/api/impl/config/PipelineConfig.java b/austin-service-api-impl/src/main/java/com/java3y/austin/service/api/impl/config/PipelineConfig.java index 6dec68c..1c7d4d1 100644 --- a/austin-service-api-impl/src/main/java/com/java3y/austin/service/api/impl/config/PipelineConfig.java +++ b/austin-service-api-impl/src/main/java/com/java3y/austin/service/api/impl/config/PipelineConfig.java @@ -49,7 +49,7 @@ public class PipelineConfig { } /** - * 普通发送执行流程 + * 消息撤回执行流程 * 1.组装参数 * 2.发送MQ * @return @@ -63,9 +63,7 @@ public class PipelineConfig { /** * pipeline流程控制器 - * 目前暂定只有 普通发送的流程 * 后续扩展则加BusinessCode和ProcessTemplate - * * @return */ @Bean diff --git a/docker/redis/redis.conf b/docker/redis/redis.conf index 15a8946..9e2083b 100644 --- a/docker/redis/redis.conf +++ b/docker/redis/redis.conf @@ -1,7 +1,7 @@ protected-mode no port 6379 timeout 0 -save 900 1 # 900s内至少一次写操作则执行bgsave进行RDB持久化 +save 900 1 save 300 10 save 60 10000 rdbcompression yes diff --git a/example/apollo.properties b/example/apollo.properties new file mode 100644 index 0000000..8ea1c1f --- /dev/null +++ b/example/apollo.properties @@ -0,0 +1,10 @@ +discard = [] +deduplication = {"deduplication_10":{"num":1,"time":300},"deduplication_20":{"num":5}} +emailAccount =[{"email_10":{"host":"smtp.qq.com","port":465,"user":"23423432@qq.com","pass":"23423432","from":"234234234@qq.com"}}] +smsAccount = [{"sms_10":{"url":"sms.tencentcloudapi.com","region":"ap-guangzhou","secretId":"234234","secretKey":"234324324","smsSdkAppId":"2343242","templateId":"234234","signName":"Java3y公众号","supplierId":10,"supplierName":"腾讯云"}},{"sms_20":{"url":"https://sms.yunpian.com/v2/sms/tpl_batch_send.json","apikey":"23423432","tpl_id":"23423432","supplierId":20,"supplierName":"云片"}}] +enterpriseWechatAccount = [{"enterprise_wechat_10":{"corpId":"23423423","corpSecret":"-234324234","agentId":1000002,"token":"234234","aesKey":"23423423"}}] +dingDingRobotAccount = [{"ding_ding_robot_10":{"secret":"234324324324","webhook":"https://oapi.dingtalk.com/robot/send?access_token=8d03b68d081f732343243242343247328b0c3003d164715d2c6c6e56"}}] +dingDingWorkNoticeAccount =[{"ding_ding_work_notice_10":{"appKey":"23423423","appSecret":"tQpvmkR863dYcuKDVfM23432432432423Nlx_fYLLLlpPJWHvWKbTu","agentId":"1523423423242"}}] +flowControl = {"flow_control_40":1} +geTuiAccount = [{"ge_tui_account_10":{"appId":"23423423","appKey":"234234234","masterSecret":"2342342342342"}}] +msg_type_sms_config = [{"message_type_10":[{"weights":99,"scriptName":"TencentSmsScript"},{"weights":1,"scriptName":"YunPianSmsScript"}]},{"message_type_20":[{"weights":20,"scriptName":"YunPianSmsScript"}]},{"message_type_30":[{"weights":20,"scriptName":"TencentSmsScript"}]},{"message_type_40":[{"weights":20,"scriptName":"TencentSmsScript"}]}] diff --git a/pom.xml b/pom.xml index 2506f6e..49b1152 100644 --- a/pom.xml +++ b/pom.xml @@ -37,7 +37,7 @@ ${target.java.version} ${target.java.version} 2.17.1 - 4.1.0 + 4.3.0