Questions tagged [spring-async]

Asynchronous execution in spring for Java. Annotating a method of a bean with @Async will make it execute in a separate thread i.e. the caller will not wait for the completion of the called method.

Asynchronous execution in spring for Java. Annotating a method of a bean with @Async will make it execute in a separate thread i.e. the caller will not wait for the completion of the called method.

150 questions
0
votes
1 answer

Why is Spring Boot @Async dropping items in my List argument?

I am experiencing some sort of thread issue with the @Async method annotation where one argument contains a List of enum and is dropping items. The list is very small, 2 items. The dropping of items is not immediate, but sometimes takes hours or…
Brandon
  • 404
  • 6
  • 21
0
votes
1 answer

Executing and handling Void @Async operations from Spring Boot resources

Java 8 and Spring Boot 2.x here. I have a RESTful resource that will kick off a long-running operation, potentially taking 15 - 20 minutes to complete in some cases. I think I want to leverage the @Async annotation here in the service-layer, but I'm…
hotmeatballsoup
  • 385
  • 6
  • 58
  • 136
0
votes
1 answer

Centralized Error Handler for Spring @TransactionalEventListener

Is there any way to specify centralized error handler for methods annotated with @TransactionalEventListener, since I want to direct certain exceptions to specific logger. Any advice would be greatly appreciated. Thanks & Regards, Jim
SetNug
  • 331
  • 1
  • 2
  • 13
0
votes
1 answer

Call a Scheduled Async bean method in a running application

I've got an Async method which is scheduled to run once a day: @Component public class MyClass { //myCronProperty set to "0 25 20 * * *" in application.properties @Scheduled(cron="{myCronProperty}") @Async @Override public void…
Ben
  • 355
  • 2
  • 11
0
votes
1 answer

Spring: Task Executor service with datetime based queue

I want to implement a Executor service for Tasks which will start running after some time, For example let's assume I have these tasks; task1 = new Task(1,10) //Task with id 1 and will start after 10 min task2 = new Task(2,15) //Task with id…
Emre EREN
  • 63
  • 1
  • 8
0
votes
0 answers

Problems when running CompletableFuture methods with java 8

I have a spring boot application, I've generated the application with jhispter, I have a spring service that has a scheduled method as below: @Scheduled(cron = "0 0/2 * * * *") private void checkStatusRouters() { if(!IS_JOB_RUNNING){ …
0
votes
1 answer

Why can't I get an open JPA session to do a migration job when I use @Async?

I had a database table that was storing 3rd party passwords in plain text. I am now updating the table to store the passwords encrypted. To handle this, I have an @EntityListener class that does the encryption and decryption post-load and…
RustyTheBoyRobot
  • 5,891
  • 4
  • 36
  • 55
0
votes
0 answers

How do I make a rest api call in a runnable?

I have a several readers where I am reading continuously for rfid tags. I want to check these tags with what is in a database. I have a spring app that uses runnables to connect and get info from the readers. I'm adding the tags to a queue. I have…
Roro
  • 427
  • 2
  • 8
  • 20
0
votes
1 answer

Problem autowiring in implementation of AsyncUncaughtExceptionHandler

I have a configuration class as such: @Configuration @EnableAsync @EnableScheduling @EnableTransactionManagement public class SpringAsyncConfiguration implements AsyncConfigurer { @Autowired private AppConfigProperties…
0
votes
0 answers

How to get task in Spring @Async Method

How to get task in Spring @Async Method? because I want to return FutureTask, but Constructor of the futureTask need to pass Runnable or Callable parameter. Before @Component public class ConversionProcessor { @Async public Future
Haven Lin
  • 176
  • 1
  • 16
0
votes
1 answer

Measure execution time of async method

I have async method where I use DeferredResult as return type. I want write junit test for that method where I call this method in loop, e.g 100 times, and I need measure execution time for every call of that method. Here is method…
Denis Stephanov
  • 4,563
  • 24
  • 78
  • 174
0
votes
1 answer

How to use CompletableFuture.thenCompose() when returning entities from repositories?

I started working with CompletableFuture in Spring Boot, and I'm seeing in some places that the usual repository methods return CompletableFuture instead of Entity. I do not know what is happening, but when I return instances of…
FMCR
  • 87
  • 6
0
votes
0 answers

Spring async and completable future unable to get result

Spring 4.3 and Java 8 Have configured the spring @Repository public class EmployeeRepostiry { @Async public CompleteableFuture getEmployee(String id) { StatusVo status = new StatusVO(); return…
0
votes
1 answer

A Sync Scheduled method runs an Async method - Spring @Scheduled, @Async

I'm using @Scheduled and @Async annotation of Spring. My purpose To schedule a sync method - which runs a for loop and this loop will run an async method, so the next value in the loop doesn't need to wait until the method is finished. See my code…
Tom
  • 85
  • 10
0
votes
0 answers

@Retryable is not working with @EventListener Spring

I have a method in class that is also a component. The method have the following annotations: @Retryable( value = { Exception.class }, maxAttempts = 2, backoff=@Backoff(delay = 2000)) @Async @EventListener For some resaon the…
nufar
  • 77
  • 2
  • 8
1 2 3
9
10