1

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.

asked Jan 6, 2023 at 14:44
4
  • "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. Commented 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/…). Commented 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/… Commented 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/… Commented Jan 8, 2023 at 16:48

2 Answers 2

0

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.

answered Jan 8, 2023 at 19:36
Sign up to request clarification or add additional context in comments.

Comments

0

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");
}}
answered Jan 19, 2023 at 7:28

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.