Akka Tech days IOCPWindows 1994 KQUEUEFRee BSD 2000
Akka의 특징 Tech. days 솔루션개발팀 • 운영체체 차원에서의 이벤트 지원 ü IOCP(Windows, 1994), KQUEUE(FRee. BSD, 2000), EPOLL(Linux, 2002) • 크로스 플랫폼 이벤트 라이브러리 등장 ü TWISTED (PYTHON, 2002), NIO (JAVA, 2004) ü LIBEVENT(2005), LIBEV(2008), LIBUV(2011) • 크로스 플랫폼 이벤트 기반 프레임웍의 등장 ü NODEJS (2009), VERT. X (2011)
Akka의 특징 • Actor Model Tech. days 솔루션개발팀
Akka의 특징 • Thead의 문제점 Shared mutable state 예측이 불가능한 상황이 만들어짐 Synchronoization monitor & lock deadlock, starvation, livelock Tech. days 솔루션개발팀
Tech. days Akka의 특징 솔루션개발팀 HTTP SSTREAM INTERFACES User App Akka HTTP Requests Single HTTP Connection Responses Client Server User App
Akka의 시작 • Akka의 시작 Apache Maven의 의존성 관리를 통해서 임포트 하거나, <dependency> <group. Id>com. typesafe. akka</group. Id> <artifact. Id>akka-actor_2. 11</artifact. Id> <version>2. 4. 17</version> </dependency> SBT의 의존성 관리를 통해서 임포트 하시면 됩니다. library. Dependencies += "com. typesafe. akka" %% "akka-actor" % "2. 4. 17" Tech. days 솔루션개발팀
Akka의 3요소 Tech. days 솔루션개발팀 • Akka의 3요소 : Actor, Actor. System, Actor. Ref Akka에서는 액터모델을 구현하기 위해 Actor. System과 Actor. Ref라는 Class를 가지고 있습니다. Akka에서 Actor. System은 역할측면에서 볼 때 스프링의 application. Context와 같다고 볼 수 있습니다. Actor의 라이프사이클이 모두 Actor. System 안에서 이루어지기 때문입니다. Actor는 Untyped. Actor를 상속받아 정의된 메서드를 구현하면 됩니다. Actor의 역할이 메시지를 받아 그 메시지를 꺼 내 적절한 비즈니스 로직을 실행하는 것이기에 일반적으로 on. Receive와 같은 메시지 도착에 따른 콜백 메서드를 구현 하여 로직을 실행 시킵니다. Untyped. Actor를 상속 받아 구현 가능한 메서드 목록은 다음을 참조하면 됩니다. 1 public class Ping. Actor extends Untyped. Actor { 2 3 private Logging. Adapter log = Logging. get. Logger(get. Context(). system(), this); 4 private Actor. Ref pong; 5 6 @Override 7 public void pre. Start() { 8 9 this. pong = context(). actor. Of(Props. create(Pong. Actor. class, get. Self()), "pong. Actor"); } 10 11 @Override 12 public void on. Receive(Object message) throws Exception { 13 if (message instanceof String) { 14 String msg = (String)message; 15 log. info("Ping received {}", msg); 16 pong. tell("ping", get. Self()); 17 18 } } 19 } 20 ▲ 링크: http: //doc. akka. io/api/akka/2. 4. 0/index. html#akka. actor. Untyped. Actor
참고자료 • 참고자료 ü 아카 공식 사이트: http: //akka. io/ ü Akka의 Use Case와 관련된 stackover. Flow 글 : http: //stackoverflow. com/questions/4493001/good-use-case-for-akka ü 책 예제 코드: https: //github. com/baekjunlim/Akka. Starting ü 책: http: //www. hanbit. co. kr/ebook/look. html? isbn=9788968487897 Tech. days 솔루션개발팀
- Slides: 33