Note that there are some explanatory texts on larger screens.

plurals
  1. POAkka Singleton - not accepting messages
    primarykey
    data
    text
    <p><em><strong></em> It was me being stupid - I wasn't passing the indexer props into system creation. I'll leave the answer here in case anyone takes some benefit *</strong></p> <p>I'm creating a singleton and sending a message like this:</p> <pre><code> val indexerProps = ClusterSingletonManager.props(had =&gt; Props( classOf[SingleCoreIndexer], dataProvider, publisher, name), name, End, None) val coreIndexer = system.actorOf(indexerProps, name) //val coreIndexer = system.actorOf(Props(classOf[SingleCoreIndexer], dataProvider, publisher, name)) coreIndexer ! "start_indexing" </code></pre> <p>The commented out line shows the non-singleton props that work fine</p> <p>When I run the app I get the following errors:</p> <pre><code>[WARN] [06/21/2013 11:55:32.443] [deadcoreindexerstest-akka.actor.default-dispatcher-5] [akka://deadcoreindexerstest/user/node1] unhandled event start_indexing in state Start </code></pre> <p>All of the other functionality stops working, which correlates with the message implying the "coreIndexer" actor is not getting the "start_indexing" message</p> <p>More code:</p> <pre><code>class Indexer(systemCreator: SystemCreator, publisherProps: Props, dataProviderProps: Props, name: String) { def start { val system = systemCreator.create val dataProvider = system.actorOf(dataProviderProps) val publisher = system.actorOf(publisherProps) val indexerProps = ClusterSingletonManager.props( singletonProps = had =&gt; Props(classOf[SingleCoreIndexer], dataProvider, publisher, name), singletonName = "aaa", terminationMessage = End, role = None ) val coreIndexer = system.actorOf(Props(classOf[SingleCoreIndexer], dataProvider, publisher, name)) coreIndexer ! "start_indexing" } } class SingleCoreIndexer(dataProvider: ActorRef, publisher: ActorRef, name: String) extends Actor { def receive = { case "start_indexing" =&gt; { println("Single core indexer starting indexing") dataProvider ! new NextBatchOfDataPlease } case BatchOfData(data) =&gt; { publisher ! (name, data) self ! "next_batch" } case "next_batch" =&gt; { dataProvider ! new NextBatchOfDataPlease } } } </code></pre> <p>It looks like I was sending a message to the manager and not the singleton. However, when I send messages to the singleton, nothing happens:</p> <pre><code>class Indexer(systemCreator: SystemCreator, publisherProps: Props, dataProviderProps: Props, name: String) { def start { val system = systemCreator.create val dataProvider = system.actorOf(dataProviderProps) val publisher = system.actorOf(publisherProps) val indexerProps = ClusterSingletonManager.props( singletonProps = had =&gt; Props(classOf[SingleCoreIndexer], dataProvider, publisher, name), singletonName = "singlecoreindexer", terminationMessage = End, role = None ) system.actorOf(Props(classOf[SingleCoreIndexer], dataProvider, publisher, name)) val coreIndexer = system.actorSelection(s"/user/$name/singlecoreindexer") coreIndexer ! "start_indexing" } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload