简体   繁体   中英

AKKA java example akka-sample-remote conf

I am very new to Akka, but so far I really like it. I have been able to get a small application running locally and now I want to test remote deployment and using remote actors.

To this end I reviewed and compiled the Java Akka 2.0.1 akka-remote-sample examples at ..

https://github.com/akka/akka/tree/master/akka-samples/akka-sample-remote

But when I try to run the compiled example ..

java -classpath `pwd`/src/main/resources:target/akka-remote-1.1.jar sample.remote.calculator.java.JCalcApp I get errors regarding the application.conf

I have made multiple attempts at tweaking the sample application.conf file but the closest I get to running the remote sample app successful is ..

Exception in thread "main" akka.remote.RemoteTransportException:Could not load remote transport layer akka.remote.netty.NettyRemoteTransport

I am using the Maven shade plugin to include all my dependencies in the jar. This worked with the local app.

Can someone please take a look at my conf file and let me know what I need to change.

Thank You !!

Here is my application.conf file ...

//#calculator
calculator {
include "common"

 akka {
    backoff-timeout = 0ms
    remote.backoff-timeout = 0ms
    remote.untrusted-mode = off
    remote.remote-daemon-ack-timeout = 30s
    remote.transport = "akka.remote.netty.NettyRemoteTransport"
    remote.log-received-messages = on
    remote.log-sent-messages = on
    remote.netty.port = 2552
  }
}
//#calculator

//#remotelookup
remotelookup {
  include "common"

  akka {
    backoff-timeout = 0ms
    remote.backoff-timeout = 0ms
    remote.untrusted-mode = off
    remote.remote-daemon-ack-timeout = 30s
    remote.log-received-messages = on
    remote.log-sent-messages = on
    remote.transport = "akka.remote.netty.NettyRemoteTransport"
    remote.netty.port = 2553
  }
}
//#remotelookup

//#remotecreation
remotecreation {
  include "common"

  akka {
    actor {
      deployment {
        /advancedCalculator {
          remote = "akka://CalculatorApplication@127.0.0.1:2552"
        }
      }
    }
    backoff-timeout = 0ms
    remote.untrusted-mode = off
    remote.remote-daemon-ack-timeout = 30s
    remote.log-received-messages = on
    remote.log-sent-messages = on
    remote.transport = "akka.remote.netty.NettyRemoteTransport"
    remote.netty.port = 2554
  }
}
//#remotecreation

and the common.conf ...

akka {

  actor {
    provider = "akka.remote.RemoteActorRefProvider"
  }

  remote {
    netty {
      hostname = "127.0.0.1"
    }
  }
} 

Okay, figured it out. Using this application.conf, the remote example will work.

Note : Also be sure to include the path to the application.conf in your classpath.

//#calculator
calculator {
  include "common"

  akka {
    remote.netty.max-total-memory-size = 0b
    remote.netty.max-channel-memory-size = 0b
    remote.netty.execution-pool-size = 4
    remote.netty.execution-pool-keepalive = 60s
    remote.netty.backlog = 4096
    remote.netty.connection-timeout = 120s
    remote.netty.outbound-local-address = "auto"
    remote.netty.message-frame-size = 1 MiB
    remote.netty.reconnect-delay = 5s
    remote.netty.all-timeout = 0s
    remote.netty.write-timeout = 0s
    remote.netty.read-timeout = 0s
    remote.netty.reconnection-time-window = 600s
    remote.netty.backoff-timeout = 0ms
    remote.netty.secure-cookie = ""
    remote.netty.require-cookie = off
    remote.netty.use-passive-connections = on
    remote.backoff-timeout = 0ms
    remote.untrusted-mode = off
    remote.remote-daemon-ack-timeout = 30s
    remote.transport = "akka.remote.netty.NettyRemoteTransport"
    remote.log-received-messages = on
    remote.log-sent-messages = on
    remote.netty.port = 2552
  }
}
//#calculator

//#remotelookup
remotelookup {
  include "common"

  akka {
    remote.netty.max-total-memory-size = 0b
    remote.netty.max-channel-memory-size = 0b
    remote.netty.execution-pool-size = 4
    remote.netty.execution-pool-keepalive = 60s
    remote.netty.backlog = 4096
    remote.netty.connection-timeout = 120s
    remote.netty.outbound-local-address = "auto"
    remote.netty.message-frame-size = 1 MiB
    remote.netty.reconnect-delay = 5s
    remote.netty.all-timeout = 0s
    remote.netty.write-timeout = 0s
    remote.netty.read-timeout = 0s
    remote.netty.reconnection-time-window = 600s
    remote.netty.backoff-timeout = 0ms
    remote.netty.secure-cookie = ""
    remote.netty.require-cookie = off
    remote.netty.use-passive-connections = on
    remote.backoff-timeout = 0ms
    remote.untrusted-mode = off
    remote.remote-daemon-ack-timeout = 30s
    remote.log-received-messages = on
    remote.log-sent-messages = on
    remote.transport = "akka.remote.netty.NettyRemoteTransport"
    remote.netty.port = 2553
  }
}
//#remotelookup

//#remotecreation
remotecreation {
  include "common"

  akka {
    actor {
      deployment {
        /advancedCalculator {
          remote = "akka://CalculatorApplication@127.0.0.1:2552"
        }
      }
    }
    remote.netty.max-total-memory-size = 0b
    remote.netty.max-channel-memory-size = 0b
    remote.netty.execution-pool-size = 4
    remote.netty.execution-pool-keepalive = 60s
    remote.netty.backlog = 4096
    remote.netty.connection-timeout = 120s
    remote.netty.outbound-local-address = "auto"
    remote.netty.message-frame-size = 1 MiB
    remote.netty.reconnect-delay = 5s
    remote.netty.all-timeout = 0s
    remote.netty.write-timeout = 0s
    remote.netty.read-timeout = 0s
    remote.netty.reconnection-time-window = 600s
    remote.netty.backoff-timeout = 0ms
    remote.netty.secure-cookie = ""
    remote.netty.require-cookie = off
    remote.netty.use-passive-connections = on
    remote.untrusted-mode = off
    remote.remote-daemon-ack-timeout = 30s
    remote.log-received-messages = on
    remote.log-sent-messages = on
    remote.transport = "akka.remote.netty.NettyRemoteTransport"
    remote.netty.port = 2554
  }
}
//#remotecreation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM