Reputation: 225
New to Akka and Actors - I need to start a few actors that will basically spend their lives reading from Kafka topics and writing to an Ignite cache. I configured my dispatcher like this:
kafka-dispatcher {
executor = "thread-pool-executor"
type = PinnedDispatcher
}
My actors are created with .withDispatcher("kafka-dispatcher")
, and my assumption is that each actor will be assigned an individual thread.
These actors basically spend their lives like this:
override def receive: Receive = LoggingReceive {
case InitWorker => {
initialize()
pollTopic() // This never returns
}
}
In other words, they receive an initialization message and then call the pollTopic()
method, which never returns - it runs a loop reading (which will block until there is data) and then writing the data.
My questions:
pollTopic()
blocks.Upvotes: 1
Views: 676
Reputation: 4100
Answering to your point 2 and from the description of what you're trying to do, maybe you want to consider using Akka streams with the reactive-kafka library. Akka streams uses actors under the hood but manages all of this for you, so you can focus only on implementing reusable small components that do exactly one thing.
You will then be able to write data processing pipelines, using Kafka as a Source
for your data flow. I don't know much about Ignite cache, but chances are you either will write a Sink
for it or - if you're talking about a blocking API, mapAsync
will be your friend.
Upvotes: 3