Java Code Examples for akka.stream.Materializer#matFromSystem()

The following examples show how to use akka.stream.Materializer#matFromSystem() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FullStackHttpIdentityProcessorVerificationTest.java    From netty-reactive-streams with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public void start() throws Exception {
    executorService = Executors.newCachedThreadPool();
    actorSystem = ActorSystem.create();
    materializer = Materializer.matFromSystem(actorSystem);
    helper = new HttpHelper(materializer);
    eventLoop = new NioEventLoopGroup();
    ProcessorHttpServer server = new ProcessorHttpServer(eventLoop);

    // A flow that echos HttpRequest bodies in HttpResponse bodies
    final Flow<HttpRequest, HttpResponse, NotUsed> flow = Flow.<HttpRequest>create().map(
            new Function<HttpRequest, HttpResponse>() {
                public HttpResponse apply(HttpRequest request) throws Exception {
                    return helper.echo(request);
                }
            }
    );

    serverBindChannel = server.bind(new InetSocketAddress("127.0.0.1", 0), new Callable<Processor<HttpRequest, HttpResponse>>() {
        @Override
        public Processor<HttpRequest, HttpResponse> call() throws Exception {
            return AkkaStreamsUtil.flowToProcessor(flow, materializer);
        }
    }).await().channel();
}
 
Example 2
Source File: HttpStreamsTest.java    From netty-reactive-streams with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public void startEventLoop() {
    eventLoop = new NioEventLoopGroup();
    actorSystem = ActorSystem.create();
    materializer = Materializer.matFromSystem(actorSystem);
    helper = new HttpHelper(materializer);
}
 
Example 3
Source File: Messenger.java    From tutorials with MIT License 5 votes vote down vote up
private CompletionStage<MessageDTO> consumeHttpResponse(HttpResponse httpResponse) {
    Materializer materializer = Materializer.matFromSystem(getContext().getSystem());
    return Jackson.unmarshaller(MessageDTO.class)
      .unmarshal(httpResponse.entity(), materializer)
      .thenApply(messageDTO -> {
          log.info("Received message: {}", messageDTO);
          discardEntity(httpResponse, materializer);
          return messageDTO;
      });
}
 
Example 4
Source File: WebSocketsTest.java    From netty-reactive-streams with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public void startEventLoop() {
    eventLoop = new NioEventLoopGroup();
    actorSystem = ActorSystem.create();
    materializer = Materializer.matFromSystem(actorSystem);
}