Last active
July 15, 2020 15:10
-
-
Save edreyer/019c7133fa949f2452aff75f41b96930 to your computer and use it in GitHub Desktop.
Spring Boot @async and Exceptions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io.vavr.control.Try; | |
import java.util.concurrent.Future; | |
import org.springframework.scheduling.annotation.Async; | |
import org.springframework.scheduling.annotation.AsyncResult; | |
class Foo {} | |
interface FooService { | |
/** Returns Future<Try<T>> for better exception handling */ | |
@Async | |
Future<Try<Foo>> getFoo(); | |
} | |
class FooServiceImpl implements FooService { | |
@Override | |
public Future<Try<Foo>> getFoo() { | |
return AsyncResult.forValue(Try.of(Foo::new)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment