io.github.spitmaster.warlock.handler.FastFailTimeoutHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of warlock-spring-boot-starter Show documentation
Show all versions of warlock-spring-boot-starter Show documentation
warlock-spring-boot-starter is an annotation-driven concurrency tools library for java with Spring.
It is easy to use in Spring application
Just using annotation on your method , the concurrency lock problem would be solved
package io.github.spitmaster.warlock.handler;
import io.github.spitmaster.warlock.exceptions.WarlockException;
import org.aopalliance.intercept.MethodInvocation;
/**
* 超时抛出异常
* 等待超时: 抛出异常, 方法不执行
* 执行超时: 抛出异常, 方法虽然执行完毕, 但丢弃返回值
*
* @author zhouyijin
*/
public enum FastFailTimeoutHandler implements WaitTimeoutHandler, LeaseTimeoutHandler {
//单例
INSTANCE;
@Override
public Object handleWaitTimeout(MethodInvocation methodInvocation) throws Throwable {
throw new WarlockException("wait timeout; timeout from " + methodInvocation.getMethod().getName());
}
@Override
public Object handleLeaseTimeout(MethodInvocation methodInvocation, Object result) throws Throwable {
throw new WarlockException("lease timeout; timeout from " + methodInvocation.getMethod().getName());
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy