아주 직관적이고 간단한 메시지전송 모델이기떄문에 여러 통신가능한 라이브러리 혹은 툴킷에서 많이 도입되었습니다.
대표적으로 고성능 Read기능을 수행하려는 메모리 DB인 Redis에도 채택된 모델이며
브라우져 지원 Websocket 라이브러리인 Socket.io / Atmosphere / SignalR 에서도 기본으로 지원하는 메시지 전송모델입니다.
간단하게 설명하면 구독을 한 사용자에게만 푸시이벤트를 날리는 기능입니다. ( 목적의 대상이 있는 실시간 메시지)
PUB/SUB 모델은 직접 구현도 가능합니다.
아래는 TopicEventBus 라는 객체를 실제로 작성하고 사용해본 샘플입니다. (이개념을 쉽게 설명하기위해 직접 개발)
다양한 언어의 시청자가 존재하는 다국어 방송 메시지 모듈
//Create Act Act System for Testing ActorSystem system = TopicEventBus.inItSystem("TestTopic"); //ActorSystem Init //Create user TopicEventBus.CreateActor("A"); TopicEventBus.CreateActor("B"); TopicEventBus.CreateActor("C"); //A user wants to receive News A in English TopicEventBus.Subscribe("A", "newsA", "en").Wait(); //User B wants to receive news A in Korean TopicEventBus.Subscribe("B", "newsA", "kr").Wait(); //Users of c want to receive News B in English TopicEventBus.Subscribe("C", "newsB", "en").Wait(); //Server real-time messages (server sprays news regardless of user) TopicEventBus.Publish("newsA", "Hi...here news A", "en"); TopicEventBus.Publish("newsA", "여기에 새로운 뉴스가 있습니다.", "kr"); TopicEventBus.Publish("newsB", "Hi...here news B", "en"); Result: create actor name:A create actor name:B create actor name:C Subscribe actor name:A to newsA Subscribe actor name:B to newsA A FirstSet LangCode en from newsA B FirstSet LangCode kr from newsA Subscribe actor name:C to newsB C FirstSet LangCode en from newsB Publish Topic:newsA msg:Hi...here news A Publish Topic:newsA msg:여기에 새로운 뉴스가 있습니다. A가 뉴스를 받음 Hi...here news A from newsA Publish Topic:newsB msg:Hi...here news B C가 뉴스를 받음 Hi...here news B from newsB B가 뉴스를 받음 여기에 새로운 뉴스가 있습니다. from newsA
저장소위치:
http://git.webnori.com/projects/AKKA/repos/topiceventbus/browse