与演员一起处理Akka HttpRequest? ActorRef actor = ...; Flow<HttpRequest, HttpResponse, NotUsed> flow = Flow .of(HttpRequest.c

与演员一起处理Akka HttpRequest? ActorRef actor = ...; Flow<HttpRequest, HttpResponse, NotUsed> flow = Flow .of(HttpRequest.c,akka,akka-http,akka-stream,akka-actor,Akka,Akka Http,Akka Stream,Akka Actor,与演员一起处理Akka HttpRequest? ActorRef actor = ...; Flow<HttpRequest, HttpResponse, NotUsed> flow = Flow .of(HttpRequest.class) .via(Flow.fromSinkAndSource( Sink .actorRef(actor, "COMPLETED"), Source

与演员一起处理Akka HttpRequest?
ActorRef actor = ...;

Flow<HttpRequest, HttpResponse, NotUsed> flow = Flow
    .of(HttpRequest.class)
    .via(Flow.fromSinkAndSource(
        Sink
            .actorRef(actor, "COMPLETED"),
        Source
            .actorRef(4, OverflowStrategy.fail())
            .mapMaterializedValue(sourceActor -> {
                actor.tell("REGISTER", sourceActor);
                return sourceActor;
            })
        ))
    .map(info -> (HttpResponse) info);

connection.handleWith(flow, materializer);
Flow<HttpRequest, HttpResponse, NotUsed> flow = Flow
    .of(HttpRequest.class)
    .via(
        .........................................................
        String token = retrieveTokenFromHttpRequest(HttpRequest);
        ActorRef actor = actorContainer.get(token);
        .........................................................
        Flow.fromSinkAndSource(
            Sink
                .actorRef(actor, "COMPLETED"),
            Source
                .actorRef(4, OverflowStrategy.fail())
                .mapMaterializedValue(sourceActor -> {
                    actor.tell("REGISTER", sourceActor);
                    return sourceActor;
                })
            )
    )
    .map(info -> (HttpResponse) info);

connection.handleWith(flow, materializer);