Home > java > Spring Async, Relationship between TaskExecutor and TaskScheduler's backing executor

Spring Async, Relationship between TaskExecutor and TaskScheduler's backing executor

February 12Hits:3

I'm attempting to customize my spring-boot applications async properties and am pretty fuzzy on the relationship between the backing Executor and Spring's TaskExecutor and TaskScheduler.

I have a @Configuration class where I create a ThreadPoolTaskScheduler and a ThreadPoolTaskExecutor

@Configuration @EnableScheduling @EnableAsync public class AsyncConfig {      @Bean(destroyMethod = "shutdown")     public TaskExecutor taskExecutor(){         ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor();         threadPoolTaskExecutor.setCorePoolSize(5);         threadPoolTaskExecutor.setMaxPoolSize(10);         threadPoolTaskExecutor.setThreadNamePrefix("executor-group");         threadPoolTaskExecutor.setQueueCapacity(Integer.MAX_VALUE);         return threadPoolTaskExecutor;     }      @Bean(destroyMethod = "shutdown")     @Autowired     public TaskScheduler taskScheduler(WebServiceDatabaseLogger webServiceDatabaseLogger){         ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler();         threadPoolTaskScheduler.setPoolSize(1);         threadPoolTaskScheduler.setErrorHandler(webServiceDatabaseLogger);         threadPoolTaskScheduler.setThreadNamePrefix("scheduler-group");         return threadPoolTaskScheduler;     }  } 

I have a single @Scheduled method and various @Async methods. I'm attempting to define a ThreadPoolExecutor with a max pool size of 10 and a core pool size of 5. From this pool I am looking for a single thread to handle my @Scheduled method and the others to execute @Async methods as needed.

I'm attempting to do this by setting the pool size on my ThreadPoolTaskScheduler to 1 but I'm not entirely sure that this is correct since I'm not sure if my ThreadPoolTaskScheduler creating its own ThreadPoolExecutor.

Also, since I'm using a fixedRate on my single @Scheduled method would there even be any benefit to increasing the ThreadPoolTaskScheduler's pool size? IE: If the pool size was 2 would it continue to execute the method sequently on different threads or would it invoke the same method in parallel according to the size of the pool?


Related Articles

  • Spring Async, Relationship between TaskExecutor and TaskScheduler's backing executorFebruary 12

    I'm attempting to customize my spring-boot applications async properties and am pretty fuzzy on the relationship between the backing Executor and Spring's TaskExecutor and TaskScheduler. I have a @Configuration class where I create a ThreadPoolTaskSc

  • Spring Async - CompletableFuture with handler after Timeout is doneFebruary 1

    I have a scenario where I call an external web service from my REST API using Spring Async. It returns a CompletableFuture and it is clear that we can wait for a time till external async operation completes. Main thread returns with Status 202 when t

  • Spring Async: How to call spring hateoas ControllerLinkBuilder inside Async methodFebruary 12

    I am calling ControllerLinkBuilder.linkTo method inside a spring Async method and it fails to find the current request. service.setUrl(linkTo(Controller.class, Controller.METHOD_GET, headers.getFirst(HEADER_SOURCE), id).toString()); Exception: java.u

  • spring async rest client orchestrate few callsFebruary 5

    I have following problem in my service I am building object X however In order to build it I need to make few http calls in order to get all required data to fill it (each rest fills certain part of the object.) In order to keep performance high I th

  • call 2 dao method using spring asynFebruary 12

    i need to know how dao transactions (using jpa and hibernate) are handled if they are called using Spring Async method. thanks and regards!

  • Async processes in Java SpringJune 19

    I need to refactor this class having in mind that the logic inside the call methods is not so short and it require spring dependencies to work, the base class I have is: @Service public class ConcurrentService{ @Autowired private Service1 service1; @

  • Spring sync vs async rest controllerJanuary 22

    I try to see a difference between Spring synchronous REST Controller vs async version of same controller. Each controller do the same thing : take a RequestBody and save it in a Mongo database. @RestController @RequestMapping ("/api/1/ticks") pu

  • Spring InvalidDataAccessApiUsageException in async method using repositoryFebruary 10

    in a RestController: @RestController @RequestMapping("/apks") public class ApkController { @Inject DecompiledApkRepository decompiledApkRepository; @Autowired DecompileService decompileService; @RequestMapping(method = RequestMethod.POST) public

  • Environment-specific code in @Async mail method with SpringMay 17

    I have a Spring @Service to asynchronously send emails. The part that seems to be a bit off to me is some code that is specific to our QA environment. We want to send and receive all emails through a test email account so that it does not impact live

  • Spring Data JPA with Hibernate - OnetoMany Relationship Mapped Entities - Partial Commit IssueJanuary 17

    I have a one to many relationship between two entity classes. When an error occurs during the insert of an child then partial insertion of parent happens but child record remains un-persisted. Here confgiured EntityManager is supposed to handle rollb

  • @Async Spring annotation doesn't workJanuary 20

    I have a method that must create a zip and mat file from the original file uploaded from the user. So I decided to store only the original file and then, in an async task I would like to create the other two files. I read that the @Async annotation h

  • Is it possible to make an async jax-ws webservice call with spring-wsJanuary 20

    I am trying to figure out if it is possible to make an async jax-ws webservice call with spring-ws? I can't find any examples of this online. I know that I can use the @Async annotation of spring to asynchronously call a method, but I want to take ad

  • Non-blocking/async Spring MVC server: designing an API for long-running REST requestsJanuary 21

    I'm learning about RX Java and Spring MVC and see we can have 'asynchronous/non-blocking' request processing flow in a REST server. Using Spring's DeferredResult type and RxJava Observable pattern gives a non-blocking thread model in the server which

  • Locate many to many extra relationship attribute with Spring data

    Locate many to many extra relationship attribute with Spring dataJanuary 22

    I have some problem with many to many query. This is part of my database and this is the code of my relationship class: @Entity @Table(name = "notification_has_user", catalog = "ats") @AssociationOverrides({ @AssociationOverride(name =

  • Relationship to a Spring Data Rest repositoryJanuary 22

    We have a relationship, a @DBref, between two entities in the model managed with a Spring Data repository based on Mongo. Now we have the need to provide one of these entities from a Rest service. How can it be solved for automatically get the relate

  • Spring WS Async SOAP Client and JMS ListenerJanuary 22

    All, I would like to create the Async. SOAP Client using Spring WS WebServiceTemplate mechanism. Is it possible? The detail use case is given below - The Client application (in Spring) will call the ESB's @OneWay SOAP Service with few parameters whic

  • Spring-Data-JPA Async Support for Save not there?January 24

    I am trying to create a non-blocking rest service with Spring Boot and Spring data JPA. How to do Async save of an entity with Spring Data JPA @Async support. Below code is not working for me although other selects seem to be working on the same enti

  • Implement Async process for external service with callback to main Request - SpringFebruary 1

    I have a design problem to solve where my application is developed using Spring. There is a REST API which have to be designed in the following way. Process request and call an external web service and get the results. Start processing -> Call Extern

  • Spring Data Neo4j 4 - How to delete Many To Many relationship and Save new RelationshipFebruary 1

    I Have relationship Many To Many between Entity A and Entity B, called Entity C. Entity B has relationship Many To One Entity D. I want to delete Relationship in Entity C to A and B, and create new Relationship A to new B and make new Entity C. Here

  • Async Spring Rest Controller - Process future resultFebruary 1

    I am new to futures and I am trying to figure out how I can process the Listenable future in this senario: @Controller @EnableAutoConfiguration public class ListenableFutureAsyncController { @Autowired IHeavyLiftingService heavyLiftingService; @Reque

Copyright (C) 2017 ceus-now.com, All Rights Reserved. webmaster#ceus-now.com 14 q. 0.395 s.