Page History
...
이경우 AKKA GRAPH DSL을 사용하여 , 비동기처리의 흐름을 제어할수 있습니다. 정확히는
비동기처리가 스트림으로 확장된형태 라고볼수 있습니다.
| Code Block | ||||
|---|---|---|---|---|
| ||||
/* construct protocol stack
* +------------------------------------+
* | stack |
* | |
* | +-------+ +---------+ |
* ~> O~~o | ~> | o~~O ~>
* Message | | codec | ByteString | framing | | ByteString
* <~ O~~o | <~ | o~~O <~
* | +-------+ +---------+ |
* +------------------------------------+
*/
val stack = codec.atop(framing)
// test it by plugging it into its own inverse and closing the right end
val pingpong = Flow[Message].collect { case Ping(id) => Pong(id) }
val flow = stack.atop(stack.reversed).join(pingpong)
val result = Source((0 to 9).map(Ping)).via(flow).limit(20).runWith(Sink.seq)
Await.result(result, 1.second) should ===((0 to 9).map(Pong)) |
...
있게하는 것이 양방향 흐름 제어(bidirectional flow) 라고 하며 하며
이것을 Java가 제공하는 Futured로만으로는 구현하기 아주 복잡해질수 있습니다.
현재는 이러한것이 있다라고만 알아두고 넘어가겠습니다.
...