Versions Compared

Key

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



Code Block
themeEmacs
implementation("com.typesafe.akka:akka-cluster-typed_$scalaVersion:$akkaVersion")





Code Block
themeEmacs
package com.example.kotlinbootlabs.actor.cluster

class ClusterActorTest {

    companion object {
        private lateinit var testKit: ActorTestKit
        private lateinit var manualTime: ManualTime

        @BeforeAll
        @JvmStatic
        fun setup() {
            val config = ManualTime.config().withFallback(ConfigFactory.defaultApplication())
            testKit = ActorTestKit.create(config)
            manualTime = ManualTime.get(testKit.system())
        }

        @AfterAll
        @JvmStatic
        fun teardown() {
            testKit.shutdownTestKit()
        }
    }

    @Test
    fun testClusterHelloActorA() {
        val probe = testKit.createTestProbe<HelloActorAResponse>()
        val actorA = testKit.spawn(ClusterHelloActorA.create())

        actorA.tell(HelloA("Hello", probe.ref))
        probe.expectMessage(HelloAResponse("Kotlin"))
    }

    @Test
    fun testClusterHelloActorB() {
        val probe = testKit.createTestProbe<HelloActorBResponse>()
        val actorB = testKit.spawn(ClusterHelloActorB.create())

        actorB.tell(HelloB("Hello", probe.ref))
        probe.expectMessage(HelloBResponse("Kotlin"))
    }

    @Test
    fun testClusterHelloActorAandB() {
        val probeA = testKit.createTestProbe<HelloActorAResponse>()
        val probeB = testKit.createTestProbe<HelloActorBResponse>()
        val actorA = testKit.spawn(ClusterHelloActorA.create())
        val actorB = testKit.spawn(ClusterHelloActorB.create())

        actorA.tell(HelloA("Hello", probeA.ref))
        probeA.expectMessage(HelloAResponse("Kotlin"))

        actorB.tell(HelloB("Hello", probeB.ref))
        probeB.expectMessage(HelloBResponse("Kotlin"))
    }
}

Image Removed

Info

 두개의 노드로 클러스터를 구성하고 싶습니다.

첫번째 노드는 Seed담당과 HelloActorA 를 
두번째 노드는 HelloActorB를 

그리고 리모트로 구성되었지만 클러스터내에서 HelloActorA가 HelloActorB에게 이벤트를 전송하는 기능을 검증

위 내용을 반영해 코드개선