score:2
Accepted answer
i don't think, it is started twice.
your create
funciton is recursive and executed whenever case subscriberschanged(actors) =>
happens.
so whenever your list of subscribers changes, you will see your log message.
you refactor create
to exclude the log message from recursion ... something like this:
def create(initialsubscribers: vector[actorref[serverevent]]): behavior[informantevent] = {
behaviors.setup { context =>
context.log.info(s"=============> start informantactor <=============")
def behavior(subscribers: vector[actorref[serverevent]]): behavior[informantevent] = behaviors.receivemessage[informantevent] {
case serverofflineconfirmed =>
subscribers.foreach(a => a ! serverofflineapproved)
behavior.same
case serveronlineconfirmed =>
subscribers.foreach(a => a ! serveronlineapproved)
behavior.same
case subscriberschanged(actors) =>
behavior(actors)
}
behavior(initialsubscribers)
}
}
Source: stackoverflow.com
Related Query
- Why does an actor start twice?
- Why does Scala sbt update every time I start it from command prompt?
- Why does the Scala IntelliJ plugin take so long to start my application?
- Why does a Scala for-comprehension have to start with a generator?
- Why does the Scala Actor implementation involve synchronized code?
- Why does specifying Xss in Maven Surefire make ScalaTest run twice as fast?
- Why does the Scala compiler recognize a generic type twice
- Why does Akka Actor have only one onReceive() method that able to take messsage
- Why does the kafka consumer code freeze when I start spark stream?
- Why does this Scala actor code require blocking to work?
- Why does the Identify message find an actor in an actor selection after its termination?
- Why does my Lift Comet Actor stops working after deployment on Jetty?
- Why does the Scala compiler disallow overloaded methods with default arguments?
- Why doesn't the example compile, aka how does (co-, contra-, and in-) variance work?
- Why does "split" on an empty string return a non-empty array?
- Why does pattern matching in Scala not work with variables?
- Any reason why scala does not explicitly support dependent types?
- Why does Scala provide both multiple parameters lists and multiple parameters per list?
- Why does join fail with "java.util.concurrent.TimeoutException: Futures timed out after [300 seconds]"?
- Why does Spark fail with java.lang.OutOfMemoryError: GC overhead limit exceeded?
- Why does a small change to this Scala code make such a huge difference to performance?
- Why does sbt compile fail with StackOverflowError?
- Why does SimpleDateFormat parse incorrect date?
- Why does Scala need parameterless in addition to zero-parameter methods?
- Why does one select Scala type members with a hash instead of a dot?
- Why does Scala choose to have the types after the variable names?
- Why does Spark fail with "Detected cartesian product for INNER join between logical plans"?
- Forward References - why does this code compile?
- Why to use empty parentheses in Scala if we can just use no parentheses to define a function which does not need any arguments?
- Why does Scala not have a return/unit function defined for each monad (in contrast to Haskell)?
More Query from same tag
- Importing classes into Scala worksheet
- What is the difference between def foo = {} and def foo() = {} in Scala?
- Why Stream/lazy val implementation using is faster than ListBuffer one
- Variable number of arguments for an abstract function
- Spark - is map function available for Dataframe or just RDD?
- Scala date time convertion using joda datetime
- Same class data member name in Trait and Case Class in Scala
- Why my Akka main actor stops even though behavior doesn't change?
- scala call-by-name - declaring parameters that aren't used
- Create table inSspark SQL doesn't support not null
- How to delete column in csv by using scala
- How to make sbt `console` use -Yrepl-sync?
- How to increment an Int value in a Map with getOrElseUpdate?
- Strange type conversion from List[(Char, Char)] to Object
- Behaviour of context bounds and implicit parameter lists with regards to path dependent types
- How to create a generic class in Scala
- Using the kronecker product on complex matrices with scalaNLP breeze
- How to test exception with Junit 4 and Scala?
- Why is the message "Akka version is not supported by Typesafe Console: 2.3.4"?
- Combine Akka config with my config
- Reusablecode for db operations with dependency injection
- Exclude scalacheck from the scala runner's classpath in Scala 2.9.2
- How do I abstract over effects and use ContextShift with Scala Cats?
- Configure Dispatcher in Akka typed actors
- Function parameter types and =>
- java.lang.IllegalArgumentException when using Play framework 2.3
- DistributedPubSubMediator Subscription via Proxy Actor not working
- unable to use multiple future of Boolean type in Scala
- Apply a function to elements inside a list of lists
- Error when connecting spark structured streaming + kafka