コード例 #1
0
  protected int executeTask() {
    int nums = 0;
    logger.debug("start execute RepeatUpChannelTask");
    List<UpChannelRecord> records = null;
    try {
      records = CacheManager.getInstance().getUpChannelRecordCache().getNeedUpChannel(100);
    } catch (CacheException e) {
      logger.error("exception when execute RepeatUpChannelTask", e);
    }
    if (records != null && !records.isEmpty()) {
      UpChannelHandler upChannelHandler = UpChannelHandler.getInstance();
      for (UpChannelRecord record : records) {
        DdoMsg ddoMsg = this.getDdoMsg(record.getDdoMsgId());
        Channel channel = this.getChannel(ddoMsg.getChannelId());
        ChannelRequest request = this.getChannelRequest(ddoMsg.getRequestId());
        if (ddoMsg != null && channel != null && request != null) {
          if (this.isNeedUpChannel(channel, request.getSourceType().intValue())) {
            upChannelHandler.handle(
                ddoMsg, request.getContent(), channel.getUpUrl(), record.getId());
          } else {
            try {
              CacheManager.getInstance().getUpChannelRecordCache().updateNoRepeat(record.getId());
            } catch (CacheException e) {
              logger.error("exception when execute RepeatUpChannelTask", e);
            }
          }

        } else {
          logger.warn(
              "the ddoMsg or channel or request is null channel is "
                  + channel
                  + ", request is "
                  + request
                  + ", ddoMsg is "
                  + ddoMsg);
        }
      }
      nums = records.size();
    }
    logger.debug("end execute RepeatUpChannelTask");
    return nums;
  }
コード例 #2
0
 /**
  * 判断是否需要上行到渠道
  *
  * @param channel
  * @return
  */
 private boolean isNeedUpChannel(Channel channel, int sourceType) {
   return (sourceType == 2 && channel.getUpUrl() != null);
 }