@Configuration
@EnableErlangDistribution
public class MyErlangConfig {
@Bean
public OtpNodeConfig otpNodeConfig() {
OtpNodeConfig config = new OtpNodeConfig();
config.setNodeName("myNode");
config.setHost("localhost");
config.setCookie("myCookie");
return config;
}
@Bean
public MyActor myActor() {
return new MyActor();
}
}
@Service
public class MyActor implements OtpActor {
@Override
public void init(OtpActorContext context) {
// initialize actor
}
@Override
public void handleMessage(OtpMsg otpMsg, OtpActorContext context) {
// handle incoming messages
}
}
public class Application {
public static void main(String[] args) {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(MyErlangConfig.class);
MyActor myActor = context.getBean(MyActor.class);
myActor.start();
}
}