Bael 1555 - Improve Example (#4852)
* BAEL-1555 * Corrected indents and spacing * RequestMapping to GetMapping * Improved Performance For Concurrent Users
This commit is contained in:
parent
aabbd93fcf
commit
a1213549f3
|
@ -13,11 +13,11 @@ import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class ResponseBodyEmitterController {
|
public class ResponseBodyEmitterController {
|
||||||
|
private ExecutorService nonBlockingService = Executors.newSingleThreadExecutor();
|
||||||
|
|
||||||
@GetMapping(Constants.API_RBE)
|
@GetMapping(Constants.API_RBE)
|
||||||
public ResponseEntity<ResponseBodyEmitter> handleRbe() {
|
public ResponseEntity<ResponseBodyEmitter> handleRbe() {
|
||||||
ResponseBodyEmitter emitter = new ResponseBodyEmitter();
|
ResponseBodyEmitter emitter = new ResponseBodyEmitter();
|
||||||
ExecutorService nonBlockingService = Executors.newSingleThreadExecutor();
|
|
||||||
|
|
||||||
nonBlockingService.execute(() -> {
|
nonBlockingService.execute(() -> {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -10,12 +10,12 @@ import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class SseEmitterController {
|
public class SseEmitterController {
|
||||||
|
private ExecutorService nonBlockingService = Executors.newSingleThreadExecutor();
|
||||||
|
|
||||||
@GetMapping(Constants.API_SSE)
|
@GetMapping(Constants.API_SSE)
|
||||||
public SseEmitter handleSse() {
|
public SseEmitter handleSse() {
|
||||||
SseEmitter emitter = new SseEmitter();
|
SseEmitter emitter = new SseEmitter();
|
||||||
|
|
||||||
ExecutorService nonBlockingService = Executors.newSingleThreadExecutor();
|
|
||||||
nonBlockingService.execute(() -> {
|
nonBlockingService.execute(() -> {
|
||||||
try {
|
try {
|
||||||
emitter.send(Constants.API_SSE_MSG + " @ " + new Date());
|
emitter.send(Constants.API_SSE_MSG + " @ " + new Date());
|
||||||
|
|
Loading…
Reference in New Issue