Skip to content

Commit 0734967

Browse files
committed
async controller
1 parent 0e73d83 commit 0734967

File tree

1 file changed

+7
-2
lines changed
  • src/main/java/com/thughari/randomchat/controller

1 file changed

+7
-2
lines changed

src/main/java/com/thughari/randomchat/controller/Ping.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
import org.springframework.web.bind.annotation.RequestMapping;
44
import org.springframework.web.bind.annotation.RestController;
5+
6+
import java.util.concurrent.CompletableFuture;
7+
8+
import org.springframework.scheduling.annotation.Async;
59
import org.springframework.web.bind.annotation.GetMapping;
610

711

@@ -10,8 +14,9 @@
1014
public class Ping {
1115

1216
@GetMapping
13-
public String ping() {
14-
return "pong";
17+
@Async("virtualThreadTaskExecutor")
18+
public CompletableFuture<String> ping() {
19+
return CompletableFuture.completedFuture("pong");
1520
}
1621

1722
}

0 commit comments

Comments
 (0)