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.
-
"Please provide a guide" isn't a good form for a StackOverflow question. Please rephrase to a specific question. Such as a specific error you are having trying to run the example in the docs.David Ogren– David Ogren2023年01月06日 18:26:46 +00:00Commented Jan 6, 2023 at 18:26
-
@DavidOgren, I had updated my question. Basically, I am looking for a main method that creates and triggers the producer and consumer in Akka Work pulling example (github.com/akka/akka/blob/v2.7.0/akka-cluster-sharding-typed/…).Nandu– Nandu2023年01月07日 13:22:37 +00:00Commented Jan 7, 2023 at 13:22
-
If you click on "source" in the snippets, it links you to the complete example in GitHub which includes a main method. github.com/akka/akka/blob/v2.7.0/akka-cluster-sharding-typed/…David Ogren– David Ogren2023年01月08日 14:48:39 +00:00Commented Jan 8, 2023 at 14:48
-
hi @DavidOgren but the source you shared is for point-to-point pattern in which the main method is present. I am checking the work pull pattern which does not includes a main method. github.com/akka/akka/blob/v2.7.0/akka-cluster-sharding-typed/…Nandu– Nandu2023年01月08日 16:48:36 +00:00Commented Jan 8, 2023 at 16:48
2 Answers 2
There is a complete sample under Akka Samples. As I said in the comments, I think you are going to have to be more specific with any issues you are having if you are running into problems.
Comments
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");
}}
Comments
Explore related questions
See similar questions with these tags.