1引入依赖

  1. <dependency>
  2. <groupId>com.xy</groupId>
  3. <artifactId>xy-core-push-boot-starter</artifactId>
  4. <version>${xy-core-push-boot-starter-version}</version>
  5. </dependency>

2.添加配置

  1. #是否开启消息推送
  2. xy.core.push.enable=true
  3. #消息推送渠道 企业微信 dingding lark
  4. xy.core.push.channel=lark
  5. #告警信息发送
  6. xy.core.push.alarm-url=https://open.larksuite.com/open-apis/bot/v2/hook/d4b9d36b-288b-4d2e-8a06-bd368d7673d7
  7. #业务逻辑通知
  8. xy.core.push.logic-url=https://open.larksuite.com/open-apis/bot/v2/hook/d4b9d36b-288b-4d2e-8a06-bd368d7673d7

3.代码编写

  1. @Service
  2. @RequiredArgsConstructor(onConstructor = @__(@Autowired))
  3. public class XxxService{
  4. private final MessageComponent messageComponent;
  5. public void sendAlarmMessage(String message){
  6. messageComponent.send(MessageType.Alarm_Message, XyEnvironmentUtils.getApplicationName() + ":" + message);
  7. }
  8. }

4.效果

lark对接 - 图1