1

I'm trying to use resizer in akka routing with round-robin-pool. But it is not creating the instances. It is working on the instances which I mentioned in the lower-bound. I'm following the documents of akka version 2.5.3.

My configuration :

akka.actor.deployment {
/round-robin-resizer {
router = round-robin-pool
resizer {
  lower-bound = 4
  upper-bound = 30
  pressure-threshold = 0
  rampup-rate = 0.5
  messages-per-resize = 1
}

}

Actor class :

return receiveBuilder()
    .match(Integer.class, msg -> {
        System.out.println("Message :  " + msg + " Thread id : " + Thread.currentThread().getId());
        Thread.sleep(5000);
    })
    .matchAny(msg -> {
         System.out.println("Error Message :  " + msg + " Thread id : " + Thread.currentThread().getId());
    }).build();

}

Creation of actor :

ActorRef roundRobin = system.actorOf(FromConfig.getInstance().props(Props.create(RoutingActor.class)), "round-robin-resizer");
    for (int i = 0; i < 15; i++) {
        roundRobin.tell(i, ActorRef.noSender());
    }

Output :

Message : 2  Thread id : 18
Message : 1  Thread id : 16
Message : 0  Thread id : 15
Message : 3  Thread id : 17
Message : 7  Thread id : 17
Message : 4  Thread id : 15
Message : 6  Thread id : 18
Message : 5  Thread id : 16
Message : 11  Thread id : 17
Message : 9  Thread id : 16
Message : 10  Thread id : 18
Message : 8  Thread id : 15
Message : 13  Thread id : 16
Message : 14  Thread id : 18
Message : 12  Thread id : 15

After every 4 result it is waiting for 5 seconds to complete the job of the previous instances.

See the thread IDs. For every creation of actor instance I'm letting my thread to sleep some time. At the time the new instance should be allocated on different thread. But this process in running till the first three instance. After that it is not creating the new instance as per the resizer. It is appending the message as per the normal flow of round robin pool.

halfer
  • 19,824
  • 17
  • 99
  • 186
Suresh Kumar
  • 172
  • 3
  • 12
  • Please read [Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers?](//meta.stackoverflow.com/q/326569) - the summary is that this is not an ideal way to address volunteers, and is probably counterproductive to obtaining answers. Please refrain from adding this to your questions. – halfer Aug 05 '17 at 08:14
  • Could you help me on this error ? – Suresh Kumar Aug 05 '17 at 09:43
  • Were you able to resolve this issue? I am getting the same problem, thanks. – Diego Ramos Jul 15 '19 at 05:22

1 Answers1

0

You are getting confused with thread-id and actual actor instance. The number of actors instances does not match with the number of threads. Please refer to this answer in other similar question: Akka ConsistentHashingRoutingLogic not routing to the same dispatcher thread consistently

hveiga
  • 6,725
  • 7
  • 54
  • 78
  • I tried with your answer to print the address path of the actor instance.But still I'm getting the same thing.It is running on the **4 instances** only. @hveiga `Message : 1 Path : akka://firstActor/user/round-robin-resizer/$b Message : 2 Path : akka://firstActor/user/round-robin-resizer/$c Message : 0 Path : akka://firstActor/user/round-robin-resizer/$a Message : 3 Path : akka://firstActor/user/round-robin-resizer/$d Message : 4 Path : akka://firstActor/user/round-robin-resizer/$a Message : 6 Path : akka://firstActor/user/round-robin-resizer/$c` – Suresh Kumar Aug 09 '17 at 05:08
  • Could you show me any simple example to verify the **Round robin pool with resizer**. @hveiga – Suresh Kumar Aug 09 '17 at 05:17