Typesafe Activator template for Akka and Spring in Java.
typesafehub / activator-akka-java-spring Goto Github PK
View Code? Open in Web Editor NEWActivator tutorial for Akka showing Java & Spring integration
License: Other
Activator tutorial for Akka showing Java & Spring integration
License: Other
Typesafe Activator template for Akka and Spring in Java.
I am trying to use this method of a Spring "extension". In my Spring java config class I have a bean defined like
... public class TestActor extends UntypedActor {...
@Bean
public TestActor testActor() {
return new TestActor();
}
Then I have a spring unit-test that loads off this Java config and does...
ActorRef testActor = myAkkaSystemBean.actorOf(SpringExtProvider.get(system).props("TestActor"),"TestActor");
Then I get this exception:
Caused by: akka.actor.ActorInitializationException: You cannot create an instance of [org.bitsofinfo.coredata.experimental.akka.TestActor] explicitly using the constructor (new). You have to use one of the 'actorOf' factory methods to create a new actor. See the documentation.
at akka.actor.ActorInitializationException$.apply(Actor.scala:173)
at akka.actor.Actor$class.$init$(Actor.scala:436)
at akka.actor.UntypedActor.<init>(UntypedActor.scala:97)
at org.bitsofinfo.coredata.experimental.akka.TestActor.<init>(TestActor.java:11)
at org.bitsofinfo.coredata.experimental.akka.AkkaConfig.testActor(AkkaConfig.java:33)
at org.bitsofinfo.coredata.experimental.akka.AkkaConfig$$EnhancerBySpringCGLIB$$204aa21.CGLIB$testActor$0(<generated>)
at org.bitsofinfo.coredata.experimental.akka.AkkaConfig$$EnhancerBySpringCGLIB$$204aa21$$FastClassBySpringCGLIB$$f4f62948.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:309)
at org.bitsofinfo.coredata.experimental.akka.AkkaConfig$$EnhancerBySpringCGLIB$$204aa21.testActor(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
... 44 common frames omitted
So my question is, how can I define all my actors in spring XML or java config, then just load them by name if constructing them, blows up like this?
Well,
this code definitely works but this technique proposed here seems hard to test.
The idea of DI when it comes to testing is to be able to mock some these dependencies to test certain behaviors. It does not seem trivial to combine the technique of the SpringActorProducer
with Akka's Testkit and say Mockito for testing.
Does someone have any code to promote this nice PoC from it works to works and tested?
I am observing a problem that when I try to create an actor and send a message to it using Spring's @PostConstruct I get a NPE exception. If I create an actor from a method call and send a message to an actor then it works. Is this a known limitation?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.