Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

점점 복잡해지고 쓸만한 Flow를 가지는 Stream처리기를 작성해보도록 하겠습니다.

 


Stream Basic2 - 비동기/동기 처리를 혼합하기

Code Block
languagejava
themeEmacs
  protected void runBasic2(){
    final Materializer materializer = ActorMaterializer.create(system);
    Source.range(1, 3)
      .map(x -> x + 1).async()
      .map(x -> x * 2)
      .to( Sink.foreach( result ->{
        log.info("runBasic2 ==> {}", result );
      }))
      .run(materializer);
  }
Expand
titleResult

2018-07-29 23:13:32,053 INFO - runBasic2 ==> 4
2018-07-29 23:13:32,054 INFO - runBasic2 ==> 6
2018-07-29 23:13:32,055 INFO - runBasic2 ==> 8