package com.neusoft.smart.pos.framework.task;

import lombok.extern.slf4j.Slf4j;

/**
 * 任务接口
 * Created by 姜涛 on 2017/3/29.
 */
@Slf4j
public abstract class RedisTask implements Runnable {
	
	private Integer counter = 0;
	
	public abstract void executeTask();
	
	private void increaseCounter() {
		this.counter += 1;
	}
	
	@Override
	public void run() {
		try {
			this.executeTask();
		} catch (Exception e) {
			log.error("第一次call 失败啦", e);
			while (this.counter < 3) {
				try {
					this.executeTask();
					break;
				} catch (Exception ee) {
					this.increaseCounter();
					log.error("重试call 失败啦",e);
				}
			}
		}
	}
}
