1

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 CompletableFuture which feeds the DeferredResult when completed.

What I am not able to figure out is:
* Will Akka exert back-pressure if this setup takes on too much load.
* If so, how can I detect that this is happening?

Kislay Verma
  • 59
  • 1
  • 10

1 Answers1

1

Consider using Alpakka's Spring Web connector, which allows integration of Akka Streams in a Spring Web application. Akka Streams provides backpressure as part of its adherence to the reactive streams specification, and the connector allows the exposure of streams as HTTP endpoints in a Spring application. An example from the Alpakka documentation:

@RestController
public class SampleController {

  @RequestMapping("/")
  public Source<String, NotUsed> index() {
    return
      Source.repeat("Hello world!")
        .intersperse("\n")
        .take(10);
  }
}

In your case, you could model your workflow as a stream.

The Akka team recently published a blog post about this connector.

Jeffrey Chung
  • 19,319
  • 8
  • 34
  • 54
  • Requirements changed and the project got shelved :) but I tried this out for a PoC and it seemed to work. Thanks for the pointer. – Kislay Verma Feb 13 '18 at 04:05