[Akka] run akka remotely into a plugin

Hello,

I would like to run akka remotely (i.e. http://doc.akka.io/docs/akka/2.4.10/scala/remoting.html) into a plugin.

First of all, I managed to run akka into a plugin in "local" mode (e.g. two actors send messages) by changing the classLoader when I create ActorSystem :  

ActorSystem system = ActorSystem.create("my-actor-sys", Config.load("common"), getClass().getClassLoader());

while I'm in my AnAction implementation.

Secondly, I ran akka remotely outside the plugin framework development (i.e. toy projects).

Finally, I tried to do it into my plugin, with all the same configuration (see the link above). The ActorSystem is not able to find the ActorRef that is running remotely (when it lookup for it, the system returns "deadLetters").

The only change we have is the ClassLoader, so i tried to build a new ClassLoader myself : https://gist.github.com/danglotb/25c99bc854067718840efd088c8a03a1 

But I have this weird exception that we have when we play with ClassLoader :

java.lang.ClassCastException: com.intellij.util.lang.UrlClassLoader cannot be cast to com.intellij.util.lang.UrlClassLoader

Could you please give me some leads to figure out this issue?

Here https://gist.github.com/danglotb/4300bd36ca2e563a05c673395df1c076 you can find a little setup.

Regards,

Benjamin.

 

Running in Intellij IDEA 2016.2.4.

Dependencies : IDEA CE IC-162.1812.17(SDK), scala 2.11.8, akka-actor 2.11-2.4.10,akka-remote 2.11-2.4.10, akka-protobuf 2.11-2.4.10, config-1.3.10 (from akka lib). dependencies to scala/akka added in the module dependencies management as external jars.

1 comment
Comment actions Permalink

Hello guys,

I managed to resolve my problem.

Config.load("common")

Does not load my own configuration file, but only the default one.

In order to fix this, I did as for the ActorSystem:

Config.load(getClass.getClassLoader(), "common")

If you any problem of configuration, you can use

system.logConfiguration()

To check if you are actually loading the desired configuration file.

Cheers,

Benjamin.

 

0

Please sign in to leave a comment.