private DdoMsg getDdoMsg(String ddoMsgId) { DdoMsg ddoMsg = null; try { ddoMsg = CacheManager.getInstance().getDdoMsgCache().getDdoMsg(ddoMsgId); } catch (CacheException e) { logger.error("exception when getDdoMsg", e); } return ddoMsg; }
private Channel getChannel(String channelId) { Channel channel = null; try { channel = CacheManager.getInstance().getChannelCache().getChannel(channelId); } catch (ElementNotFoundException e) { logger.error("exception when getChannel", e); } return channel; }
private ChannelRequest getChannelRequest(String requestId) { ChannelRequest request = null; try { request = CacheManager.getInstance().getChannelRequestCache().getChannelRequest(requestId); } catch (CacheException e) { logger.error("exception when getChannelRequest", e); } return request; }
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; }