akka fails silently while serializing TypedActor proxies and ActorRef across 32 bit and 64 bit JVMs

244 Views Asked by At

What configuration is required to fix the following problem? Akka Actor on 64 bit jvm(machine1) CANNOT use TypedActor proxies on the 32 bit jvm(machine2) (CASE1) but WORKS vice versa (CASE2).

Is there some configuration setting for serialization I'm missing out? I'm using akka-2.2.1 from java.

I've a small test code which replicates this problem always.

There are no logs which report "ERRORS", despite enabling even remote-lifecycle events. It just times out when calling registerListener() on CASE1.

I'm clueless, any help/clue is greatly appreciated.

server.java

public class Server implements ServerActor {

    public static final String serverActorName = "server";
    public static final String serverIP = "192.168.11.112";
    public static final int serverPort = 9999;

    public static void main(String[] args) {
        new Server();
    }

    ActorSystem serverSystem;

    public Server() {

        String network = String
                .format("akka.actor.provider = \"akka.remote.RemoteActorRefProvider\" \n"
                        + "akka.remote.enabled-transports = [\"akka.remote.netty.tcp\"] \n"
                        + "akka.remote.netty.tcp.hostname = \"%s\" \n"
                        + "akka.remote.netty.tcp.port = %d", Server.serverIP,
                        Server.serverPort);

        Config config = ConfigFactory.parseString("akka.loglevel = DEBUG \n"
                + "akka.actor.debug.lifecycle = on \n" + network);

        serverSystem = ActorSystem.create("sys", config);

        RemoteActorRefProvider ref = (RemoteActorRefProvider) serverSystem
                .provider();
        Address addr = ref.transport().defaultAddress();
        String port = addr.port().get().toString();

        System.out.printf("Server Akka IP=%s PORT=%s\n", addr, port);

        final Server server = this;

        // start server service
        @SuppressWarnings("unused")
        ServerActor proxy = TypedActor.get(serverSystem).typedActorOf(
                new TypedProps<Server>(ServerActor.class,
                        new Creator<Server>() {

                            private static final long serialVersionUID = 6301999771454618282L;

                            @Override
                            public Server create() {
                                return server;
                            }
                        }), Server.serverActorName);

    }

    @Override
    public boolean registerListener(ITestListener listener) {
        listener.update(10);
        return true;
    }

}

And client.java

public class Client implements ITestListener {

    public static final String clientActorName = "client";
    public static final String clientIP = "192.168.11.111";

    public static void main(String[] args) {
        new Client();
    }

    ActorSystem clientSystem;
    private ITestListener clientListener = null;

    public Client() {

        String network = String
                .format("akka.actor.provider = \"akka.remote.RemoteActorRefProvider\" \n"
                        + "akka.remote.enabled-transports = [\"akka.remote.netty.tcp\"] \n"
                        + "akka.remote.netty.tcp.hostname = \"%s\" \n"
                        + "akka.remote.netty.tcp.port = 0", Client.clientIP);

        Config config = ConfigFactory.parseString("akka.loglevel = DEBUG \n"
                + "akka.actor.debug.lifecycle = on \n" + network);

        clientSystem = ActorSystem.create("sys", config);

        RemoteActorRefProvider ref = (RemoteActorRefProvider) clientSystem
                .provider();
        Address addr = ref.transport().defaultAddress();
        String port = addr.port().get().toString();

        System.out.printf("Client Akka IP=%s PORT=%s\n", addr, port);

        final Client client = this;

        // start server service
        clientListener = TypedActor.get(clientSystem).typedActorOf(
                new TypedProps<Client>(ITestListener.class,
                        new Creator<Client>() {

                            private static final long serialVersionUID = 2034444366744329184L;

                            @Override
                            public Client create() {
                                return client;
                            }
                        }), Client.clientActorName);

        connect();

    }

    private void connect() {

        // Connect to remote actor system
        String remotePath = String.format("akka.tcp://sys@%s:%d/user/%s",
                Server.serverIP, Server.serverPort, Server.serverActorName);

        // get remote server proxy object
        // TypedActor.context().setReceiveTimeout(Duration.create("3 second"));
        ActorRef remoteRef = clientSystem.actorFor(remotePath);

        if (remoteRef == null)
            throw new RuntimeException("Cannot get remote akka actor");

        final ServerActor server = TypedActor.get(clientSystem).typedActorOf(
                new TypedProps<ServerActor>(ServerActor.class), remoteRef);

        server.registerListener(clientListener);

    }

    @Override
    public void update(int a) {
        System.out.printf("*********** Server Sent %d ************\n", a);
    }
}
0

There are 0 best solutions below