This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// on the client | |
val initialContacts = Set( | |
system.actorSelection("akka.tcp://Other@host1:2552/user/receptionist"), | |
system.actorSelection("akka.tcp://Other@host2:2552/user/receptionist")) | |
val c = system.actorOf(ClusterClient.props(initialContacts)) | |
c ! ClusterClient.Send("/user/serviceA", "hello", localAffinity = true) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
akka.cluster.role { | |
frontend.min-nr-of-members = 1 | |
backend.min-nr-of-members = 2 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Copyright (C) 2009-2014 Typesafe Inc. <http://www.typesafe.com> | |
*/ | |
package akka.contrib.mailbox | |
import scala.concurrent.duration._ | |
import java.util.concurrent.atomic.AtomicInteger | |
import java.util.concurrent.atomic.AtomicLong | |
import com.typesafe.config.Config | |
import akka.actor.{ ActorContext, ActorRef, ActorSystem, ExtendedActorSystem } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val selection = context.actorSelection( | |
"akka.tcp://[email protected]:2552/user/world") | |
selection ! "hello" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val selection = context.actorSelection( | |
"akka.tcp://[email protected]:2552/user/world") | |
selection ! Identify(None) | |
var ref: ActorRef = _ | |
def receive = { | |
case ActorIdentity(_, Some(actorRef)) => | |
ref = actorRef | |
context watch ref | |
case ActorIdentity(_, None) => // not alive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case object Register | |
class Master extends Actor { | |
var workers = Set.empty[ActorRef] | |
def receive = { | |
case Register => | |
workers += sender | |
context watch sender | |
case Terminated(ref) => |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package sample.cluster.simple | |
import scala.concurrent.duration._ | |
import akka.actor._ | |
import akka.cluster.Cluster | |
import akka.cluster.ClusterEvent._ | |
import akka.routing.FromConfig | |
import com.typesafe.config.ConfigFactory | |
object SimpleRouterApp { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object TopicAssistant { | |
case class Subscribe(topic: String) | |
case object SubscribeAck | |
} | |
// Start this actor with name "topicAssistant" on each node in the cluster | |
class TopicAssistant extends Actor { | |
import TopicAssistant._ | |
ClusterReceptionistExtension(context.system).registerService(self) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Copyright (C) 2009-2013 Typesafe Inc. <http://www.typesafe.com> | |
*/ | |
package akka.contrib.pattern | |
import akka.actor.ActorIdentity | |
import akka.actor.Props | |
import akka.actor.ActorSelection | |
import scala.concurrent.duration.Deadline | |
import akka.actor.ReceiveTimeout |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import akka.actor.Actor.Receive | |
import akka.actor.ActorContext | |
import akka.actor.ActorLogging | |
import akka.actor.Actor | |
import akka.event.LoggingAdapter | |
object MyLoggingReceive { | |
def apply(log: LoggingAdapter)(r: Receive)(implicit context: ActorContext): Receive = r match { | |
case _: MyLoggingReceive ⇒ r |