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
3
votes
0 answers

Example for spring MVC DeferredResult with long running task

Can anyone tell me, how to do long running transactional task using spring DeferredResult ? went through a lot of tutorial available on net but neither documentation nor examples clear on non Rest based application, which doesn't need long polling…
Sreekanth
  • 539
  • 1
  • 7
  • 24
2
votes
0 answers

How to check currently running thread under given Task Executor with Spring @Async

I am not creating bean explicitly. I am using @EnableAsync and spring…
G10
  • 118
  • 1
  • 8
2
votes
0 answers

How does Spring handle annotations when an overridden method exists on multiple supertypes?

Consider the following scenario: A class called EventHandlerImpl implements an interface called AsyncEventHandler, with a single handle() method marked with the Spring @Async annotation. EventHandlerImpl also extends an abstract superclass called…
2
votes
3 answers

How to assert exceptions in @Async void methods?

I want to assert an exception that should be thrown within an @Async void method. The following fails, even though I already add a SyncTaskExecutor explicit. org.opentest4j.AssertionFailedError: Expected RuntimeException to be thrown, but nothing…
membersound
  • 81,582
  • 193
  • 585
  • 1,120
2
votes
1 answer

Call Rest API by Spring RestTemplate within a @Async method

As I know, Spring RestTemplate is synchronous and blocks the thread until the web client receives the response, and Spring WebClient is asynchronous and non-blocking. But what if we call an API using RestTemplate within an @Async annotated…
2
votes
2 answers

Interrupt all threads if an exception occurs in any

I have a method name someTask that I have to invoke 100 times and I am using asynchronous coding as below. for (int i = 0; i < 100; i++) { futures.add(CompletableFuture.supplyAsync( () -> { someTask(); }, myexecutor …
2
votes
2 answers

Spring Web Flux and Spring Async method what is the difference?

I am new to Spring Reactive programming and Spring Async methods. I have a doubt. By using spring webflux we can have reactive programming so that we can execute a particular piece of code and our current thread need not to wait for it to finish the…
Abhishek Dash
  • 43
  • 1
  • 6
2
votes
4 answers

boot @Async : what is best way to create 1000 no of threads using spring

I need to process 600 million of records in multithreaded way and each request takes 5-6 seconds. In boot application i need to create 1000 threads but tomcat supports 200 only. what is the best way to proceed?
Udayan
  • 31
  • 3
2
votes
0 answers

Is it possible to resubmit a task to a Spring @Async method?

I have a Spring method annotated with @Async @Async public void doSomething(long id, String text) { //do something } The method invokes a remote service, which occasionally times out. Is there a way to catch the timeout and resubmit the task to…
Rich
  • 15,602
  • 15
  • 79
  • 126
2
votes
1 answer

Get exception thrown within annotated @Async method in @RestControllerAdvice

There is a quite similar question here, but the answer does not suffice for my question. I have this method in a @Service class: @Async public void activateUser(...){ if(someCondition){ throw new GeneralSecurityException(); } } The…
akuma8
  • 4,160
  • 5
  • 46
  • 82
2
votes
1 answer

@Async does not work in spring

I have a spring boot application and want to run a simple Async background task by using @async annotation , however , this does not seem to be working (no new threads are created and I wait until the sleep fininshes after each call to the function…
Mohammed Fathi
  • 1,237
  • 1
  • 14
  • 12
2
votes
2 answers

Threadpool used in one @Async method getting shared with other async method executions

I have a thread-pool initialized as a @Bean for purpose of dedicated execution of a particular @Async method class MyConfig { @Bean(name="myPool") public static TaskExecutor getExecutor(){ ThreadPooltaskExecutor exec = new…
Ashish Mishra
  • 303
  • 4
  • 10
2
votes
1 answer

Multiple AsyncAnnotationBeanPostProcessor within spring context

I have a spring project. When I run the project on tomcat, I get the following error - Only one AsyncAnnotationBeanPostProcessor may exist within the context. Now I know that the reason is that I have following in applicationContext.xml -…
Popeye
  • 1,548
  • 3
  • 25
  • 39
2
votes
1 answer

How to implement request timeout management in an AOP way in Spring Boot

currently I'm exploring approaches to implement 'request timeout management in an AOP way in Spring Boot' with several restrictions. The requirements/restrictions are stated as below: The original purpose is that if the processing time of an api…
2
votes
0 answers

proxy error when creating a bean with an @Async method

I have edited this as I realised I had misdiagnosed the cause of the error. The error is caused because I have an async method in the abstract class which is being instantiated by the bean. I've added this method to the abstract class below. If I…
gringogordo
  • 1,990
  • 6
  • 24
  • 60
1 2
3
9 10