| | |
| | | import com.zy.core.action.ShuttleAction; |
| | | import com.zy.core.enums.RedisKeyType; |
| | | import com.zy.core.enums.SlaveType; |
| | | import com.zy.core.utils.TimeoutExecutor; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | public class ShuttleExecuteScheduler implements Runnable { |
| | | |
| | |
| | | //存在任务需要执行 |
| | | long startTime = System.currentTimeMillis(); |
| | | News.info("execute {},{}", deviceConfig.getDeviceNo(), taskNo); |
| | | boolean result = shuttleAction.executeWork(deviceConfig.getDeviceNo(), taskNo); |
| | | // 在循环中使用 |
| | | boolean result = TimeoutExecutor.executeWithTimeout( |
| | | () -> shuttleAction.executeWork(deviceConfig.getDeviceNo(), taskNo), |
| | | 30, // 30秒超时 |
| | | TimeUnit.SECONDS |
| | | ); |
| | | Thread.sleep(100); |
| | | News.info("execute end {},{},{}", deviceConfig.getDeviceNo(), taskNo, System.currentTimeMillis() - startTime); |
| | | } |