Versions Compared

Key

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

...

Expand
title수행결과

[INFO] [05/18/2018 13:26:18.720] [AkkaTestApp-akka.actor.default-dispatcher-4] [Workers] Workers::Received String message: hi1

[INFO] [05/18/2018 13:26:18.726] [AkkaTestApp-akka.actor.default-dispatcher-2] [TestActor] akka://AkkaTestApp/user/workers/router1/$a::Incommessage hi1
[INFO] [05/18/2018 13:26:18.732] [AkkaTestApp-akka.actor.default-dispatcher-2] [Workers] Workers::Received String message: hi1
[INFO] [05/18/2018 13:26:18.733] [AkkaTestApp-akka.actor.default-dispatcher-5] [TestActor] akka://AkkaTestApp/user/workers/router1/$b::Incommessage hi1
[INFO] [05/18/2018 13:26:18.733] [AkkaTestApp-akka.actor.default-dispatcher-5] [Workers] Workers::Received String message: hi1
[INFO] [05/18/2018 13:26:18.733] [AkkaTestApp-akka.actor.default-dispatcher-5] [Workers] Workers::Received String message: hi1
[INFO] [05/18/2018 13:26:18.733] [AkkaTestApp-akka.actor.default-dispatcher-5] [Workers] Workers::Received String message: hi1
[INFO] [05/18/2018 13:26:18.733] [AkkaTestApp-akka.actor.default-dispatcher-3] [TestActor] akka://AkkaTestApp/user/workers/router1/$c::Incommessage hi1
[INFO] [05/18/2018 13:26:18.733] [AkkaTestApp-akka.actor.default-dispatcher-5] [Workers] Workers::Received String message: hi1
[INFO] [05/18/2018 13:26:18.733] [AkkaTestApp-akka.actor.default-dispatcher-3] [TestActor] akka://AkkaTestApp/user/workers/router1/$d::Incommessage hi1
[INFO] [05/18/2018 13:26:18.733] [AkkaTestApp-akka.actor.default-dispatcher-5] [Workers] Workers::Received String message: hi1
[INFO] [05/18/2018 13:26:18.733] [AkkaTestApp-akka.actor.default-dispatcher-4] [TestActor] akka://AkkaTestApp/user/workers/router1/$e::Incommessage hi1
[INFO] [05/18/2018 13:26:18.733] [AkkaTestApp-akka.actor.default-dispatcher-9] [TestActor] akka://AkkaTestApp/user/workers/router1/$b::Incommessage hi1
[INFO] [05/18/2018 13:26:18.734] [AkkaTestApp-akka.actor.default-dispatcher-3] [TestActor] akka://AkkaTestApp/user/workers/router1/$a::Incommessage hi1

Info

위 작성된 코드에서, 랜던 라우트를 추가해보고 작동방식을 확인해보겠습니다.

얼마나 최소의 코드로 기존 가진기능을 유지하면서 기능추가가되는지 확인해보겠습니다.

Code Block
languagejava
themeEmacs
//router2 설정
		/workers/router2 {
			router = random-pool
			nr-of-instances = 5
		}
// 랜덤풀 생성
randomPool = getContext().actorOf( FromConfig.getInstance().props( ext.props("testActor") ) , "router2");


//hi1을 받으면 라우드로빈, hi2를 받으면 랜덤풀로 작동된다.
		.matchEquals("hi1",s->{
			log.info("Workers::Received String message: {}", s);
			roundrobinpool.tell(s, getSender() );					
		})
		.matchEquals("hi2",s->{
			log.info("Workers::Received String message: {}", s);
			randomPool.tell(s, getSender() );					
		})

Expand
title작동결과

[INFO] [05/18/2018 13:50:08.645] [AkkaTestApp-akka.actor.default-dispatcher-6] [TestActor] akka://AkkaTestApp/user/workers/router2/$e::Incommessage hi2
[INFO] [05/18/2018 13:50:08.645] [AkkaTestApp-akka.actor.default-dispatcher-4] [Workers] Workers::Received String message: hi2
[INFO] [05/18/2018 13:50:08.645] [AkkaTestApp-akka.actor.default-dispatcher-4] [Workers] Workers::Received String message: hi2
[INFO] [05/18/2018 13:50:08.645] [AkkaTestApp-akka.actor.default-dispatcher-12] [TestActor] akka://AkkaTestApp/user/workers/router2/$a::Incommessage hi2
[INFO] [05/18/2018 13:50:08.645] [AkkaTestApp-akka.actor.default-dispatcher-6] [TestActor] akka://AkkaTestApp/user/workers/router2/$e::Incommessage hi2
[INFO] [05/18/2018 13:50:08.645] [AkkaTestApp-akka.actor.default-dispatcher-4] [Workers] Workers::Received String message: hi2
[INFO] [05/18/2018 13:50:08.645] [AkkaTestApp-akka.actor.default-dispatcher-8] [TestActor] akka://AkkaTestApp/user/workers/router2/$d::Incommessage hi2
[INFO] [05/18/2018 13:50:08.645] [AkkaTestApp-akka.actor.default-dispatcher-4] [Workers] Workers::Received String message: hi2
[INFO] [05/18/2018 13:50:08.645] [AkkaTestApp-akka.actor.default-dispatcher-6] [TestActor] akka://AkkaTestApp/user/workers/router2/$b::Incommessage hi2
[INFO] [05/18/2018 13:50:08.645] [AkkaTestApp-akka.actor.default-dispatcher-4] [Workers] Workers::Received String message: hi2
[INFO] [05/18/2018 13:50:08.645] [AkkaTestApp-akka.actor.default-dispatcher-4] [Workers] Workers::Received String message: hi2
[INFO] [05/18/2018 13:50:08.645] [AkkaTestApp-akka.actor.default-dispatcher-6] [TestActor] akka://AkkaTestApp/user/workers/router2/$c::Incommessage hi2