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
/** | |
* 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
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
// 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
class Publisher extends Actor { | |
import DistributedPubSubMediator.Publish | |
// activate the extension | |
val mediator = DistributedPubSubExtension(context.system).mediator | |
def receive = { | |
case in: String ⇒ | |
val out = in.toUpperCase | |
mediator ! Publish("content", out) | |
} |
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
Cluster(system) registerOnMemberUp { | |
system.actorOf(Props(classOf[FactorialFrontend], upToN, true), | |
name = "factorialFrontend") | |
} |
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 akka.contrib.mailbox | |
import java.util.concurrent.ConcurrentHashMap | |
import java.util.concurrent.atomic.AtomicInteger | |
import com.typesafe.config.Config | |
import akka.actor.{ ActorContext, ActorRef, ActorSystem, ExtendedActorSystem, Extension, ExtensionId, ExtensionIdProvider } | |
import akka.dispatch.{ Envelope, MailboxType, MessageQueue, UnboundedMailbox, UnboundedQueueBasedMessageQueue } | |
object MetricsMailboxExtension extends ExtensionId[MetricsMailboxExtension] with ExtensionIdProvider { | |
def lookup = this |
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
// sort by age, oldest first | |
val ageOrdering = Ordering.fromLessThan[Member] { (a, b) => | |
a.isOlderThan(b) | |
} | |
var membersByAge: SortedSet[Member] = SortedSet.empty(ageOrdering) | |
def receive = { | |
case state: CurrentClusterState => | |
membersByAge = SortedSet.empty(ageOrdering) ++ state.members | |
} |
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
class TransformationBackend extends Actor { | |
val cluster = Cluster(context.system) | |
override def preStart(): Unit = | |
cluster.subscribe(self, classOf[MemberUp]) | |
override def postStop(): Unit = | |
cluster.unsubscribe(self) | |
def receive = { | |
case state: CurrentClusterState ⇒ |
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 language.postfixOps | |
import scala.concurrent.duration._ | |
import com.typesafe.config.ConfigFactory | |
import akka.actor.Actor |