I am writing the setting of my disptacher in addtional conf file and then loading it in application.conf but dispatcher is not working when i am giving the full path where the dispatcher located in my file i am also assuring that it dispatcher exsits or not by using if statarements
val config = ConfigFactory.load()
// an actor needs an ActorSystem
val system = ActorSystem("TestActorSystem",config)
if(system.dispatchers.hasDispatcher("akka.actor.directUserWriteMongoActor-dispatcher"))
{println("directUserWriteMongoActor-dispatcher exists")}
else
{
println("dispatcher does not exists")
}
when i run that directUserWriteMongoActor-dispatcher exists printed on console but when i try to attached it via code
val DirectUserWriteMongoActor = system.actorOf(Props[DirectUserWriteMongoActor].withDispatcher("akka.actor.directUserWriteMongoActor-dispatcher"), name = "directwritemongoactorr")
DirectUserWriteMongoActor ! DirectUserWriteToMongo(directUser)
log indicate that it is using default-dispatcher rather then my own dispatcher named directUserWriteMongoActor-dispatcher here is my full code
application.conf
include "DirectUserWriteMongoActor"
akka {
loggers = ["akka.event.slf4j.Slf4jLogger"]
loglevel = "DEBUG"
}
DirectUserWriteMongoActor.conf
akka {
loggers = ["akka.event.slf4j.Slf4jLogger"]
loglevel = "DEBUG"
actor{
loggers = ["akka.event.slf4j.Slf4jLogger"]
loglevel = "DEBUG"
############################### Setting for a Dispatcher #####################################
directUserWriteMongoActor-dispatcher {
type = Dispatcher
executor = "fork-join-executor"
fork-join-executor {
parallelism-min = 2
parallelism-factor = 2.0
parallelism-max = 10
}
throughput = 10
} #end default-dispatcher
} #end Actor
} #end Akka
and here is my code
object TestActor extends App{
val config = ConfigFactory.load()
val system = ActorSystem("TestActorSystem",config)
if(system.dispatchers.hasDispatcher("akka.actor.directUserWriteMongoActor-dispatcher"))
{println("directUserWriteMongoActor-dispatcher exists")}
else
{
println("directUserWriteMongoActor-dispatcher does not exists")
}
val DirectUserWriteMongoActor = system.actorOf(Props[DirectUserWriteMongoActor].withDispatcher("akka.actor.directUserWriteMongoActor-dispatcher"), name = "directwritemongoactorr")
DirectUserWriteMongoActor ! DirectUserWriteToMongo(directUser)
DirectUserWriteMongoActor.scala
case class DirectUserWriteToMongo (directuser:DirectUser)
class DirectUserWriteMongoActor extends Actor{
val log = Logging(context.system, this)
def receive = {
case DirectUserWriteToMongo(directuser) =>
log.debug("writing to mogo")
log.info("message received DirectUserWriteInMongo")
val directUserStore= new directUserStore
log.info("going to call store in mongo")
}}
here is the output printed on console
2015-04-27 10:40:01.392 INFO Slf4jLogger [TestActorSystem-akka.actor.default-dispatcher-2] -Slf4jLogger started
directUserWriteMongoActor-dispatcher exists
2015-04-27 10:40:02.262 INFO DirectUserWriteMongoActor [TestActorSystem-akka.actor.default-dispatcher-3] akka://TestActorSystem/user/directwritemongoactorr -message received DirectUserWriteInMongo
2015-04-27 10:40:02.263 INFO DirectUserWriteMongoActor [TestActorSystem-akka.actor.default-dispatcher-3] akka://TestActorSystem/user/directwritemongoactorr -going to call store in mongo
please help me what is wrong in my code or in my conf setting disptacher was there but it is not working why os that so This should be printed
TestActorSystem-akka.actor.directUserWriteMongoActor-dispatcher-3
instead of this
TestActorSystem-akka.actor.default-dispatcher-3
please help me also i am using akka dispatch and additional conf files for the very first time