delay retry

添加重试

delayQueueManager.add(DelayQueueTypeEnum.FEE_CANCEL, cancelFeeRetryMsg, 3);
  • DelayQueueTypeEnum.FEE_CANCEL:重试的类型,消费消息时,根据该类型定位对应的handler
  • cancelFeeRetryMsg:请求参数
  • 3: retrytime

封装重试context&发送延时消息

DelayContext delayContext = new DelayContext();
delayContext.setKey(typeEnum.toString());//DelayQueueTypeEnum
delayContext.setParam(JSON.toJSONString(obj));// param
delayContext.setCreateTime(System.currentTimeMillis());
delayContext.setRetryTimes(retryTimeTemp);
//判断当前重试次数
if (curExecuteCnt > delayContext.getRetryTimes()) {
  return;
}
//发送延时消息 RETRY_TIMES_STRATEGY中定义了第几次延时多长时间,故取到的是延时时长  
delayMqProducer.asynSendMsg(delayContext, getTopic(), RETRY_TIMES_STRATEGY[curExecuteCnt - 1]);