I am interested in understanding the work pull feature in akka. I am trying to create a main method for the example provided that will create and start the producer(ImageWorkManager class in the example) and consumer(ImageConverter class in the example). It will be helpful if someone provides a sample main method for executing the sample example.
I had figured it out. Below is the main class to create a producer actor in the given work pull example.
public class WorkPullCreateProducer {
public static void main(String[] args) {
final ActorSystem<Command> system = ActorSystem.create(ImageWorkManager.create(), "ClusterSystem");
final ActorRef<Command> ref = system;
Convert img = new Convert("gif", "jpeg", "imagename");
ref.tell(img);
}}
and below is the main class to create a consumer actor.
public class WorkPullCreateConsumer {
public static Behavior<Void> create() {
return Behaviors.setup(context -> {
int workersPerNode = context.getSystem().settings().config().getInt("transformation.workers-per-node");
for (int i = 0; i < workersPerNode; i++) {
context.spawn(ImageConverter.create(), "Workernode" + i);
}
return Behaviors.empty();
});
}
public static void main(String[] args) {
ActorSystem.create(AppWorkPullConsumerStack.create(), "ClusterSystem");
}}