Questions tagged [deferred-result]

DeferredResult provides an alternative to using a Callable for asynchronous request processing. While a Callable is executed concurrently on behalf of the application, with a DeferredResult the application can produce the result from a thread of its choice.

19 questions
2
votes
0 answers

How to enable Async in springboot testing using webmvctest?

This my test case: @Test public void sampleTestCase(int parm1, int parm2, Integer expectedReturnedMessageCode, String expectedReturnedparm2, Integer expectedReturnedparm1) throws Exception { MvcResult result = mockMvc …
2
votes
0 answers

How to use zuul to intercept async requests(DeferredResult)?

I am coding a notification system. The clients will get notification from the server by http-long-polling(Spring async requests with DeferredResult). Now I need to limit the total connection the server can hold and the max connection count a client…
2
votes
0 answers

Thread.sleep in the spring controller

I'm working on a legacy system where they have Thread.sleep in the controller. The scenario here is, once the request is received it polls another service until the criteria are met. The problem here is request processing thread is blocked because…
Thiru
  • 2,541
  • 4
  • 25
  • 39
2
votes
0 answers

AsyncHandlerInterceptor - ASYNC dispatcher request not called while client closes

Well, this is an exceptional behavior, one needed for our use-case. We are using handler interceptor to "increment active request count" at "preHandle" method. On "afterCompletion" method we decrement the active request counter. So far so good.…
Delwar
  • 21
  • 3
1
vote
0 answers

Prevent blocking DeferredResult

I have a method which blocks the thread and then returns a value. In order to prevent the web server from getting exhausted with blocked threads, I planned to use DeferredResult. I tried to demonstrate it by setting the server.tomcat.max-threads=1…
sam
  • 1,800
  • 1
  • 25
  • 47
1
vote
0 answers

Spring boot interceptor - Perform a blocking network call to another service

We would like to perform validation on all the API endpoints inside our spring boot application. The validation logic relies on passing few request properties to another service S and getting the validation result from this remote service S. This…
prk68
  • 176
  • 11
1
vote
0 answers

Spring Web MVC: Perform FORWARD with DeferredResult

We use DeferredResult in Controller methods. How is it possible to perform a FORWARD to another controller method? I am aware of how to perform a REDIRECT, but I do not want the round trip to the browser and back. I am also aware of how to perform a…
SLO
  • 11
  • 1
1
vote
1 answer

concurrency problems in interceptor tracking MDC

I have the following interceptor that tracks request/response based on saving and restoring some vars stored in MDC context for every request. public class LoggingInterceptor implements DeferredResultProcessingInterceptor { private final…
jorgebo10
  • 450
  • 4
  • 13
1
vote
1 answer

Backpressure in a Spring DeferredResult + Akka actors application

I am thinking of using a chain of Akka workers to model a workflow inside a DeferredResult based Spring MVC web application. Essentially the controller will return a DeferredResult and the actors in the chain will work to populate a…
Kislay Verma
  • 59
  • 1
  • 10
1
vote
0 answers

Asynchronous API get blocked after processing N requests

I developed a simple asynchronous API in Scala using Spring MVC. In the Controller I am using DeferredResult> response = new DeferredResult<>(360000L,new String("PROCESSING_TIMEOUT")); in order to return the message…
HackerDuck
  • 249
  • 1
  • 5
  • 17
1
vote
0 answers

Is it possible to run an AsyncWebRequest via browser call?

I'm using Spring Boot 1.4. @RequestMapping("/nonblocking/{identifier}") fun get(@PathVariable identifier: String): DeferredResult> { logger.info("Starting call") val dr = DeferredResult>() …
dierre
  • 7,140
  • 12
  • 75
  • 120
0
votes
1 answer

How to understand when a ReadbleStream is closed from the server [Using DeferredResult on Server side]?

I have implemented the a polling using DeferredResult in Spring and on the client side I handle the data I receive form the server. In the client side I have a simple page with plain javascript: // start polling (ignore placeholder) function…
AM13
  • 661
  • 1
  • 8
  • 18
0
votes
0 answers

DeferredResult deferring HTTP thread but not returning to browser

I get some of the idea of async services, but haven't coded many, so the mechanics especially in Java are new to me. Basically, I have a long running service that I want to fork off to another thread and be able to check in on the status of it using…
0
votes
0 answers

Response is sent back very late after setting the DeferredResult setResult method

I have a REST Controller, implemented using Spring MVC. The controller sets the DeferredResult setResult method with the response received after validations, from the service method. df.setResult(responseobj); However, the worker thread is not…
Saurav Ojha
  • 145
  • 1
  • 1
  • 7
0
votes
2 answers

Directly setting deferred result does not return a body

I am using Spring Boot 2.0 and have an endpoint in an @RestController that returns a DeferredResult and in some cases (e.g. if the wanted value does not need to be computed) it sets the result on that DeferredResult directly like so: …
rodalfus
  • 166
  • 2
  • 14
1
2