spring boot 实现 Stream 钉钉事件订阅

avatar
作者
猴君
阅读量:0

1: 参考链接   

https://open.dingtalk.com/document/orgapp/develop-stream-mode-push-server

2:钉钉开放平台订阅配置

配置之后运行一下上面提供的链接 里面的main方法,验证通道

3:订阅启动方式

EventListenerThread eventListenerThread = application.getBean(EventListenerThread.class); // 启动EventListenerThread eventListenerThread.start();
@Override public void run() {     OpenDingTalkStreamClientBuilder                                  .custom()                                  .credential(new AuthClientCredential(appKey, appSecret))                                  //注册事件监听                       .registerAllEventListener(new GenericEventListener() {                           public EventAckStatus onEvent(GenericOpenDingTalkEvent event) {                              try {                                  //事件唯一Id                                  String eventId = event.getEventId();                                  //事件类型                                  String eventType = event.getEventType();                                  //事件产生时间                                   Long bornTime = event.getEventBornTime();                                   //获取事件体                                  JSONObject bizData = event.getData();                                   log.info("当前时间"+ TimeUtils.date2Str(new Date()));                                  // Create InputStream from byte array                                  log.info("进入事件订阅:eventId "+eventId+"eventType"+eventType+"bornTime"+bornTime);                                   //处理事件                                   evetTypeEvent(eventId,eventType,bornTime,bizData);                                   //消费成功                                  return EventAckStatus.SUCCESS;                               } catch (Exception e) {                                  //消费失败                                 return EventAckStatus.LATER;                              }                          }                       })                                 .build().start(); }

广告一刻

为您即时展示最新活动产品广告消息,让您随时掌握产品活动新动态!