zoukankan      html  css  js  c++  java
  • 极光推送的的栗子

     // 比赛结束的推送消息
        @Override
        public void sendMessageForGameOver(String gameId) {
    
            ExecutorService fixedThreadPool = Executors.newFixedThreadPool(100);  //设置此线程等待10分钟
            fixedThreadPool.execute(new MessageForGameOver(gameId));
        }
    
        class MessageForGameOver implements Runnable {
            private String  gameId;
            public MessageForGameOver(String  gameId) {
                this.gameId = gameId;
            }
            public void startEvent(){
                try{
                    //获取主队的所有球员的Id
                    Game gameOverDto=gameService.getGameRaw(gameId);
                    String homeTeamId = gameOverDto.getHomeTeamId();
                    List<String> homeTeamUserIds = getUserIdsByTeamId(homeTeamId);
                    //获取客队的所有球员的Id
                    String guestTeamId = gameOverDto.getGuestTeamId();
                    List<String> guestTeamUserIds = getUserIdsByTeamId(guestTeamId);
    
                    PushMessageDto homeTeamDto = genPushMessageDtoService.genPushMessageDtoForGameOver(gameOverDto, homeTeamUserIds, gameOverDto.getGuestTeamId());
                    PushMessageDto guestTeamDto = genPushMessageDtoService.genPushMessageDtoForGameOver(gameOverDto, guestTeamUserIds, gameOverDto.getHomeTeamId());
                    PushMessage pushMessage = new PushMessage();
                    pushMessage.setBizid(gameId);
                    pushMessage.setBiztype(2);
                    pushMessage.setProcessStatus(2);
                    pushMessage.setProcessCount(0);
                    pushMessage.setCreatedTime(new Date());
                    pushMessage.setUpdatedTime(new Date());
                    PushMessage message = pushMessageService.insertSelective(pushMessage);
    
                    saveMessageDetailService.saveMessageDetailForGameOver(gameOverDto);
                    sendMessageToJpush(homeTeamDto, guestTeamDto, message);
                }catch (Exception e){
                    log.error("消息发送出错"+e.getMessage());
                }
            }
    
            @Override
            public void run() {
                try {
                    Thread.sleep(10*60*1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                startEvent();
            }
        }
    

      

  • 相关阅读:
    K&R C C90,C99的改进
    Windows 用来定位 DLL 的搜索路径
    常量字符串的问题
    C++0x中一些有用的新特性
    mainfest机制
    mainfest机制
    C++0x中一些有用的新特性
    c语言目标程序中的段
    c语言目标程序中的段
    数据模型(LP32 ILP32 LP64 LLP64 ILP64 )
  • 原文地址:https://www.cnblogs.com/murong/p/5920203.html
Copyright © 2011-2022 走看看