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?

4

1 回答 1

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.

于 2017-12-19T18:33:47.133 回答