This is a simple actor system implemented for the purpose of learning. It is not intended to be used in production.
Java 19 is required to build and run the project. Preview features are used.
public class MyActor extends AbstractActor {
@Override
public void process(Message<?> msg) {
ActorRef from = msg.getSender();
if (from != null) {
msg.setSender(this);
msg.setSenderName(name);
from.send(msg);
}
}
}
public class Main {
public static void main(String[] args) {
ActorProxy proxy = new ActorContext.spawnActor("my-actor", new MyActor());
proxy.send(new Message<>("Hello World!"));
System.out.println(proxy.<Message<String>>receive().getBody());
}
}
To build the project, run ./gradlew build
. This will build the project and run the tests.
The tests are written using JUnit 5. To run the tests, run ./gradlew test
.
This will run the tests and generate a test report in build/reports/tests/test/index.html
.
To run the tests with code coverage, run ./gradlew jacocoTestReport
.
This will generate a report in build/reports/jacoco/test/html/index.html
.
The documentation is written using Javadoc. To generate the documentation, run ./gradlew javadoc
.
This will generate the documentation in build/docs/javadoc/index.html
.
A simple benchmark is included in the project. The benchmark is run using JMH.
To run the benchmark, run ./gradlew jmh
. This will run the benchmark and generate a result file in
build/results/jmh/results.txt
.
The benchmark measures the time it takes to process 100 entire rounds in a ring of 100 RingActor
actors.
In the rpc
package, there is an RPC api to use the actor system remotely. The RPC api is implemented using
XMLRPC and JSONRPC. The RPC api is not intended to be used in production, as underlying libraries
(Apache XMLRPC and JSONRPC)
are outdated and have known vulnerabilities (see CVE report for Apache XMLRPC,
CVE report for JSONRPC).
To start the RPC server, run ./gradlew appRun
. This will start the XMLRPC and JSONRPC servlets (using tomcat 9)
on port 8080, accessible at http://localhost:8080/xmlrpc
and http://localhost:8080/jsonrpc
, respectively.
To try out the RPC server, you can use the Actor System UI.