From a1213549f3cc8a9692e5f8b67c1944c8478a2455 Mon Sep 17 00:00:00 2001 From: Adam InTae Gerard Date: Mon, 30 Jul 2018 22:41:59 -0700 Subject: [PATCH] Bael 1555 - Improve Example (#4852) * BAEL-1555 * Corrected indents and spacing * RequestMapping to GetMapping * Improved Performance For Concurrent Users --- .../java/com/baeldung/web/ResponseBodyEmitterController.java | 2 +- .../src/main/java/com/baeldung/web/SseEmitterController.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-5-mvc/src/main/java/com/baeldung/web/ResponseBodyEmitterController.java b/spring-5-mvc/src/main/java/com/baeldung/web/ResponseBodyEmitterController.java index 4af8eb9bd3..ff1fb87393 100644 --- a/spring-5-mvc/src/main/java/com/baeldung/web/ResponseBodyEmitterController.java +++ b/spring-5-mvc/src/main/java/com/baeldung/web/ResponseBodyEmitterController.java @@ -13,11 +13,11 @@ import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter @Controller public class ResponseBodyEmitterController { + private ExecutorService nonBlockingService = Executors.newSingleThreadExecutor(); @GetMapping(Constants.API_RBE) public ResponseEntity handleRbe() { ResponseBodyEmitter emitter = new ResponseBodyEmitter(); - ExecutorService nonBlockingService = Executors.newSingleThreadExecutor(); nonBlockingService.execute(() -> { try { diff --git a/spring-5-mvc/src/main/java/com/baeldung/web/SseEmitterController.java b/spring-5-mvc/src/main/java/com/baeldung/web/SseEmitterController.java index 390178aaef..944aec2559 100644 --- a/spring-5-mvc/src/main/java/com/baeldung/web/SseEmitterController.java +++ b/spring-5-mvc/src/main/java/com/baeldung/web/SseEmitterController.java @@ -10,12 +10,12 @@ import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; @Controller public class SseEmitterController { + private ExecutorService nonBlockingService = Executors.newSingleThreadExecutor(); @GetMapping(Constants.API_SSE) public SseEmitter handleSse() { SseEmitter emitter = new SseEmitter(); - ExecutorService nonBlockingService = Executors.newSingleThreadExecutor(); nonBlockingService.execute(() -> { try { emitter.send(Constants.API_SSE_MSG + " @ " + new Date());