Quantcast
Channel: Akka Libraries - Discussion Forum for Akka technologies
Viewing all articles
Browse latest Browse all 1367

Cannot Find a Topic using the Receptionist

$
0
0

After having created a Topic as system actor, I tried to look them up with Receptionist.Find but nothing was found. The same problem occurs, when the Topic is created using ordinary spawn.

Here my simple test:

    @Test
    public void findTopic() throws Exception {
        ActorSystem<Void> system = ActorSystem.create(Behaviors.empty(), "Root");

        ServiceKey<Topic.Command> topicServiceKey = ServiceKey.create(Topic.Command.class, "MyTopic");

        ActorRef<Topic.Command<String>> topicRef = system.systemActorOf(Topic.create(String.class, "MyTopic"), "MyTopicRef", Props.empty());
        
        CompletionStage<Receptionist.Listing> result =
                AskPattern.ask(
                        system.receptionist(),
                        sendListingTo -> Receptionist.find(topicServiceKey, sendListingTo),
                        Duration.ofSeconds(5),
                        system.scheduler());

        Receptionist.Listing listing = result.toCompletableFuture().get(5, TimeUnit.SECONDS);

        Set<ActorRef<Topic.Command>> refs = listing.getServiceInstances(topicServiceKey);
        assertThat(refs.size()).isEqualTo(1); //<== FAILS size is 0
    }

What I’m doing wrong? I’m using Akka 2.6.18

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 1367

Trending Articles