Esempio n. 1
0
 public static void main(String[] args) {
   DataSource dataSource = SpringContextUtil.getBean("dataSource");
   try {
     ResultSet resultSet = dataSource.getConnection().prepareCall("xxx").executeQuery();
     if (resultSet.next()) {
       resultSet.getInt("");
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
Esempio n. 2
0
  @Override
  public void run() {
    log.info("ShareMsgPopThread is running…………");
    RedisUtils redisUtils = SpringContextUtil.getBean("redisUtils");
    RecordShareService recordShareService = SpringContextUtil.getBean("recordShareService");

    if (null == redisUtils) {
      log.info("redisUtils is null…………");
      return;
    }

    while (true) {
      try {
        // 休眠固定时间
        Thread.sleep(syncTimeInterval * Constants.ONE_SECOND_MS);

        // 从redis中获取
        String shareMsg = redisUtils.lpop(Constants.REDIS_SHARE_MSG);
        if (StringUtils.isEmpty(shareMsg)) {
          continue;
        }
        log.info("shareMsg=" + shareMsg);

        // openId:分享者id  scene:场景
        JSONObject job = JSONObject.parseObject(shareMsg);
        String openId = job.getString("openId");
        String scene = job.getString("scene");
        if (StringUtils.isEmpty(openId) || StringUtils.isEmpty(scene)) {
          continue;
        }
        RecordShare model = new RecordShare(openId, scene);
        log.info("shareMsg=" + shareMsg + ", result=" + recordShareService.add(model));
      } catch (Exception e) {
        log.info("error![shareMsg]  errMsg=" + e.getMessage());
        e.printStackTrace();
      }
    }
  }