ping with executor

This commit is contained in:
anhefti 2023-05-31 20:30:12 +02:00
parent 2a16813cd7
commit b344ee22e5
4 changed files with 26 additions and 32 deletions

View file

@ -74,15 +74,6 @@ public class AsyncServiceSpringConfig implements AsyncConfigurer {
return executor; return executor;
} }
// @Bean
// public ThreadPoolTaskScheduler threadPoolTaskScheduler() {
// final ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler();
// threadPoolTaskScheduler.setPoolSize(5);
// threadPoolTaskScheduler.setWaitForTasksToCompleteOnShutdown(false);
// threadPoolTaskScheduler.setThreadNamePrefix("SEB-Server-BgTask-");
// return threadPoolTaskScheduler;
// }
@Override @Override
public Executor getAsyncExecutor() { public Executor getAsyncExecutor() {
return threadPoolTaskExecutor(); return threadPoolTaskExecutor();

View file

@ -101,7 +101,7 @@ public class WebserviceInfo {
this.distributedUpdateInterval = environment.getProperty( this.distributedUpdateInterval = environment.getProperty(
"sebserver.webservice.distributed.updateInterval", "sebserver.webservice.distributed.updateInterval",
Long.class, Long.class,
3000L); 2000L);
this.activeProfiles = new HashSet<>(Arrays.asList(environment.getActiveProfiles())); this.activeProfiles = new HashSet<>(Arrays.asList(environment.getActiveProfiles()));

View file

@ -325,8 +325,9 @@ public class ExamAPI_V1_Controller {
method = RequestMethod.POST, method = RequestMethod.POST,
consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE) produces = MediaType.APPLICATION_JSON_VALUE)
public void ping(final HttpServletRequest request, final HttpServletResponse response) { public CompletableFuture<Void> ping(final HttpServletRequest request, final HttpServletResponse response) {
return CompletableFuture.runAsync(
() -> {
final String connectionToken = request.getHeader(API.EXAM_API_SEB_CONNECTION_TOKEN); final String connectionToken = request.getHeader(API.EXAM_API_SEB_CONNECTION_TOKEN);
//final String pingNumString = request.getParameter(API.EXAM_API_PING_NUMBER); //final String pingNumString = request.getParameter(API.EXAM_API_PING_NUMBER);
final String instructionConfirm = request.getParameter(API.EXAM_API_PING_INSTRUCTION_CONFIRM); final String instructionConfirm = request.getParameter(API.EXAM_API_PING_INSTRUCTION_CONFIRM);
@ -348,6 +349,8 @@ public class ExamAPI_V1_Controller {
log.error("Failed to send instruction as response: {}", connectionToken, e); log.error("Failed to send instruction as response: {}", connectionToken, e);
} }
} }
},
this.executor);
} }
@RequestMapping( @RequestMapping(

View file

@ -40,7 +40,7 @@ sebserver.webservice.internalSecret=${sebserver.password}
### webservice networking ### webservice networking
sebserver.webservice.forceMaster=false sebserver.webservice.forceMaster=false
sebserver.webservice.distributed=false sebserver.webservice.distributed=false
sebserver.webservice.distributed.updateInterval=3000 sebserver.webservice.distributed.updateInterval=2000
sebserver.webservice.http.external.scheme=https sebserver.webservice.http.external.scheme=https
sebserver.webservice.http.external.servername= sebserver.webservice.http.external.servername=
sebserver.webservice.http.external.port= sebserver.webservice.http.external.port=