Skip to content

Conversation

@ssrijan-007-sys
Copy link
Contributor

@ssrijan-007-sys ssrijan-007-sys commented Apr 14, 2025

Description

This PR adds an implementation of the Actor Model pattern in Java as part of the ongoing effort to expand the collection of design patterns in this repository.

What's Included:

  • src/: Core Java classes implementing the Actor Model (Actor, Message, ActorSystem, PrinterActor, and App)
  • README.md: Description of the pattern, explanation, example usage, and when to apply
  • etc/: UML class diagram in both .png and .urm.puml format
  • pom.xml: Maven module configuration
  • Added the pattern module to the root pom.xml

Closes #3232

Checklist ✅

  • Code follows the Google Java Style Guide
  • Code formatted using the Spotless Maven plugin (./mvnw spotless:apply)
  • Pattern directory includes:
    • src/
    • README.md
    • etc/ with diagrams
    • pom.xml
  • Pattern added to parent pom.xml
  • All links in README.md are relative
  • Project compiles successfully using ./mvnw clean install

Let me know if there are any required changes or improvements. I'm happy to collaborate and iterate!

@github-actions
Copy link

github-actions bot commented Apr 14, 2025

PR Summary

This PR implements the Actor Model pattern in Java. It includes core classes (Actor, Message, ActorSystem), a sample application (App), UML diagrams, and a comprehensive README.

Changes

File Summary
actor-model/README.md This file provides a detailed explanation of the Actor Model pattern, including its intent, explanation, class diagram, participants, applicability, and an example.
actor-model/etc/actor-model.urm.puml This file contains a PlantUML class diagram that visually represents the structure and relationships of the classes in the Actor Model implementation.
actor-model/etc/actor_model-Actor_Model___UML_Class_Diagram.png This file is a PNG image of the UML class diagram for the Actor Model, providing a visual representation of the classes and their relationships.
actor-model/pom.xml This file configures the Maven project for the Actor Model module, defining dependencies and project metadata.
actor-model/src/main/java/com/iluwatar/actormodel/Actor.java This class defines the Actor base class, which handles incoming messages sequentially using a mailbox. It includes methods for sending messages and stopping the actor.
actor-model/src/main/java/com/iluwatar/actormodel/ActorSystem.java This class implements the ActorSystem, which creates and manages actors. It uses an executor service for concurrent execution and a concurrent hash map for actor registration.
actor-model/src/main/java/com/iluwatar/actormodel/App.java This class demonstrates the usage of the Actor Model pattern with two example actors that exchange messages.
actor-model/src/main/java/com/iluwatar/actormodel/ExampleActor.java This class is an example implementation of an actor that logs received messages and responds to them.
actor-model/src/main/java/com/iluwatar/actormodel/ExampleActor2.java This class is a second example actor implementation that simply logs received messages.
actor-model/src/main/java/com/iluwatar/actormodel/Message.java This class represents a message exchanged between actors, containing the message content and sender ID.
pom.xml The root pom.xml file was modified to include the newly added actor-model module.

autogenerated by presubmit.ai

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Review Summary

Commits Considered (2)
Files Processed (10)
  • actor-model/README.md (1 hunk)
  • actor-model/etc/actor-model.urm.puml (1 hunk)
  • actor-model/etc/actor_model-Actor_Model___UML_Class_Diagram.png (0 hunks)
  • actor-model/pom.xml (1 hunk)
  • actor-model/src/main/java/com/iluwatar/actormodel/Actor.java (1 hunk)
  • actor-model/src/main/java/com/iluwatar/actormodel/ActorSystem.java (1 hunk)
  • actor-model/src/main/java/com/iluwatar/actormodel/App.java (1 hunk)
  • actor-model/src/main/java/com/iluwatar/actormodel/ExampleActor.java (1 hunk)
  • actor-model/src/main/java/com/iluwatar/actormodel/Message.java (1 hunk)
  • pom.xml (2 hunks)
Actionable Comments (0)
Skipped Comments (0)

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
12.8% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Review Summary

Commits Considered (1)
  • 11abf48: feat: update Actor Model implementation with multi-actor logic #3251
Files Processed (7)
  • actor-model/src/main/java/com/iluwatar/actormodel/Actor.java (1 hunk)
  • actor-model/src/main/java/com/iluwatar/actormodel/ActorSystem.java (1 hunk)
  • actor-model/src/main/java/com/iluwatar/actormodel/App.java (1 hunk)
  • actor-model/src/main/java/com/iluwatar/actormodel/ExampleActor.java (1 hunk)
  • actor-model/src/main/java/com/iluwatar/actormodel/ExampleActor2.java (1 hunk)
  • actor-model/src/main/java/com/iluwatar/actormodel/Message.java (1 hunk)
  • pom.xml (2 hunks)
Actionable Comments (0)
Skipped Comments (0)

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Review Summary

Commits Considered (1)
  • dd1dcdd: Merge branch 'iluwatar:master' into actor-model
Files Processed (0)
Actionable Comments (0)
Skipped Comments (0)

ssrijan-007-sys added a commit to ssrijan-007-sys/java-design-patterns that referenced this pull request Apr 15, 2025
ssrijan-007-sys added a commit to ssrijan-007-sys/java-design-patterns that referenced this pull request Apr 15, 2025
ssrijan-007-sys added a commit to ssrijan-007-sys/java-design-patterns that referenced this pull request Apr 16, 2025
iluwatar pushed a commit that referenced this pull request Apr 22, 2025
* feat: Implement Actor Model pattern #3232

* feat: Implement Actor Model pattern #3232

* feat: update Actor Model implementation with multi-actor logic #3251

* feat: update Actor Model implementation with multi-actor logic and loose coupling  #3251

* test: add unit test for actor model #3251

* test: add test for App.java to increase coverage

* docs: add complete README for Actor Model pattern also implemented changes #3251
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Actor Model pattern

1 participant