0
0
Spring Bootframework~10 mins

Why async processing matters in Spring Boot - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to enable asynchronous processing in a Spring Boot method.

Spring Boot
@[1]
public void processTask() {
    // task logic here
}
Drag options to blanks, or click blank then click option'
AEnableAsync
BAsync
CAsyncMethod
DAsyncProcessing
Attempts:
3 left
💡 Hint
Common Mistakes
Using @EnableAsync on a method instead of a configuration class
Misspelling the annotation name
Forgetting the '@' symbol
2fill in blank
medium

Complete the code to enable async support in a Spring Boot application.

Spring Boot
@Configuration
@[1]
public class AsyncConfig {
}
Drag options to blanks, or click blank then click option'
AAsyncEnabled
BAsyncSupport
CAsyncConfiguration
DEnableAsync
Attempts:
3 left
💡 Hint
Common Mistakes
Placing @EnableAsync on a method instead of a configuration class
Using @Async instead of @EnableAsync here
Misspelling the annotation
3fill in blank
hard

Fix the error in the method signature to return a future result asynchronously.

Spring Boot
@Async
public [1]<String> fetchData() {
    // fetch data logic
}
Drag options to blanks, or click blank then click option'
ACompletableFuture
BFuture
CListenableFuture
DOptional
Attempts:
3 left
💡 Hint
Common Mistakes
Using Future which is less flexible
Using Optional which is not for async
Using ListenableFuture without proper dependencies
4fill in blank
hard

Fill both blanks to create a method that runs asynchronously and returns a completed future.

Spring Boot
@Async
public CompletableFuture<String> [1]() {
    return CompletableFuture.[2]("Done");
}
Drag options to blanks, or click blank then click option'
ArunTask
BcompletedFuture
CsupplyAsync
DexecuteTask
Attempts:
3 left
💡 Hint
Common Mistakes
Using supplyAsync inside the method without executor
Choosing method names that don't describe an action
Returning incomplete futures
5fill in blank
hard

Fill all three blanks to configure a custom executor bean for async processing.

Spring Boot
@Bean
public Executor [1]() {
    ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
    executor.setCorePoolSize([2]);
    executor.setMaxPoolSize([3]);
    executor.initialize();
    return executor;
}
Drag options to blanks, or click blank then click option'
AtaskExecutor
B5
C10
DasyncExecutor
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong bean name that conflicts with defaults
Setting core pool size larger than max pool size
Forgetting to initialize the executor