Created
March 7, 2021 16:46
-
-
Save njofce/c785a4c0578792123693dcdc04a620af to your computer and use it in GitHub Desktop.
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
public class FeignClient { | |
public static void main(String[] args) throws ExecutionException, InterruptedException { | |
synchronousTest(); | |
asyncTest(); | |
} | |
private static void synchronousTest() { | |
FileApi fileApi = FileApiFactory.getSynchronousFileAPI(); | |
FileMetadata file1 = fileApi.getFile("file1"); | |
System.out.println("Loaded from server: " + file1.fileName); | |
} | |
private static void asyncTest() throws ExecutionException, InterruptedException { | |
AsyncFileApi asyncFileAPI = FileApiFactory.getAsyncFileAPI(); | |
CompletableFuture<FileMetadata> file = asyncFileAPI.getFile("file2"); | |
String id = file.thenApply(f -> "ID: " + f.id).get(); | |
System.out.println("Loaded asynchronously the file with id: " + id); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment