Skip to content

Instantly share code, notes, and snippets.

@rogeralsing
Created October 6, 2015 10:56
Show Gist options
  • Save rogeralsing/1affb84c004682c206d8 to your computer and use it in GitHub Desktop.
Save rogeralsing/1affb84c004682c206d8 to your computer and use it in GitHub Desktop.
import akka.actor.{Actor, Props, ActorRef, ActorSystem}
import com.typesafe.config.ConfigFactory
import scala.concurrent.duration._
object Program {
def main(args: Array[String]): Unit = {
val conf = ConfigFactory.load(ConfigFactory.parseString("""
akka{
stdout-loglevel = WARN
loglevel = WARN
log-config-on-start = off
}
akka.actor {
provider = "akka.cluster.ClusterActorRefProvider"
}
akka.remote {
log-remote-lifecycle-events = off
netty.tcp {
hostname = "127.0.0.1"
port = 2551 //<- change this to 2552 for seed node 2
}
}
akka.cluster {
seed-nodes = [
"akka.tcp://[email protected]:2551"
"akka.tcp://[email protected]:2552"
]
auto-down = on
}
akka.log-dead-letters=1000
"""))
val system = ActorSystem.create("ClusterSystem",conf)
val worker = system.actorOf(Props[Worker])
worker ! "test"
println("starting node...")
val res = scala.io.StdIn.readLine()
println(res)
}
}
class Worker extends Actor{
import context._
def receive = {
case str: String => {
println("sending...")
context.system.actorSelection("akka.tcp://[email protected]:8090/user/dummy").tell("hello", self)
context.system.scheduler.scheduleOnce(1.second,self,"hello")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment