Skip to content

biddyweb/elasticactors

 
 

Repository files navigation

Elastic Actors

Persistent Stateful Actor System

Current released version

0.17.1

Add Elastic Actors to your Project

repository:

<repositories>
    <repository>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
        <id>elasticsoftwarefoundation</id>
        <name>bintray</name>
        <url>http://dl.bintray.com/elasticsoftwarefoundation/maven</url>
    </repository>
</repositories>

minimal dependency:

<dependency>
    <groupId>org.elasticsoftware.elasticactors</groupId>
    <artifactId>elasticactors-api</artifactId>
    <version>${elasticactors.version}/version>
</dependency>

convenient base classes inclusing a Jackson 2 based serialization framework:

<dependency>
    <groupId>org.elasticsoftware.elasticactors</groupId>
    <artifactId>elasticactors-base</artifactId>
    <version>${elasticactors.version}</version>
</dependency>

Example code

Some example code (in java)

@Message(serializationFramework = JacksonSerializationFramework.class,durable = true)
public class Greeting {
    private final String who;

    @JsonCreator
    public Greeting(@JsonProperty("who") String who) {
        this.who = who;
    }

    public String getWho() {
        return who;
    }
}

@Actor(stateClass = StringState.class,serializationFramework = JacksonSerializationFramework.class)
public class GreetingActor extends TypedActor<Greeting> {
    @Override
    public void onReceive(ActorRef sender, Greeting message) throws Exception {
        System.out.println("Hello " + message.getWho());
    }
}

TestActorSystem testActorSystem = new TestActorSystem();
testActorSystem.initialize();

ActorSystem actorSystem = testActorSystem.getActorSystem();
ActorRef greeter = actorSystem.actorOf("greeter",GreetingActor.class);
greeter.tell(new Greeting("Joost van de Wijgerd"),null);

testActorSystem.destroy();

About

Persistent Stateful Actor System

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 99.7%
  • Protocol Buffer 0.3%