Versions Compared

Key

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

...

라우팅 전략은 다양한 유입처리를 어떻게 분배하여 성능적 또는 안정적으로 유실없이 모두 처리할것인가?에

대한것으로 이러한것을  AKKA를 사용하면 서비스코드내에 직접 설계가 가능하도록합니다.

물론 이러한 목표를 달성하기위해 KAFKA와 같은 외부 MQ를 잘 사용하는것도 방법중에 하나일것입니다.

라우팅은 주로 분배및 작동방식을 의미를 하고, 라우티는 실제 Task를 처리할수있는 종단점에 위치한 액터입니다.

라우팅 방법 설정

Code Block
languagebash
themeEmacs
titleapplication.conf
akka { 
 actor.deployment {
 /workers/router1 {
 router = round-robin-pool
 nr-of-instances = 5
 }
 } 
}

...

Code Block
languagejava
themeEmacs
	protected void routerTest(ActorSystem system,SpringExtension ext) {
	    new TestKit(system) {{
	    	final ActorRef workers = system.actorOf( ext.props("workers"),"workers");  // workers 액터생성	    		    
	    	workers.tell( "hi1", getRef() );
		      // await the correct response
		    expectMsg(java.time.Duration.ofSeconds(1), "hi too"); //라우티가 응답한 메시지를 검사
		    
	    	workers.tell( "hi1", getRef() );
		      // await the correct response
		    expectMsg(java.time.Duration.ofSeconds(1), "hi too");


		    workers.tell( "hi1", getRef() );
		    workers.tell( "hi1", getRef() );
		    workers.tell( "hi1", getRef() );
		    workers.tell( "hi1", getRef() );
		    workers.tell( "hi1", getRef() );
	    }};
	}



Expand
title수행결과

[INFO] [05/1718/2018 2013:1426:3218.578720] [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::preStart::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/1718/2018 2013:1426:3218.590733] [AkkaTestApp-akka.actor.default-dispatcher-45] [Workers] Workers::Received String message: hihi1
[INFO] [05/1718/2018 2013:1426:3218.596733] [AkkaTestApp-akka.actor.default-dispatcher-3] [TestActor] akka://AkkaTestApp/user/workers/router1/$a$c::Incommessage hi hi1
[INFO] [05/18/2018 13:26:18.733] [AkkaTestApp-akka.actor.default-dispatcher-5] [Workers] Workers::Received String message: hi1
[INFO] [05/1718/2018 2013:1426:3218.603733] [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: hi: 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/1718/2018 2013:1426:3218.603733] [AkkaTestApp-akka.actor.default-dispatcher-69] [TestActor] akka://AkkaTestApp/user/workers/router1/$b::Incommessage hi1
[INFO] [05/18/2018 13:26:Incommessage hi18.734] [AkkaTestApp-akka.actor.default-dispatcher-3] [TestActor] akka://AkkaTestApp/user/workers/router1/$a::Incommessage hi1