Re: [akka-user] akka.actor.PreRestartException Happening whenever there is restart

2016-03-23 Thread Biniam Asnake
Thank you. I solved the issue by checking for *message.isEmpty()* rather 
than *null*.

@Override
void preRestart (Throwable reason, Option message) throws Exception {

log.error("preRestart called at ${self()}. Error: ${reason?.message}.")

if(!message.isEmpty()) {

self().tell(message.get(), sender())
log.error("preRestart: Resending message class: '${message.getClass()}' 
to ${self()}.")
}

super.preRestart(reason, message)
}




On Friday, March 11, 2016 at 3:45:52 PM UTC+1, Akka Team wrote:
>
> Option.get does not return null for an empty option, it throws an 
> exception.
>
> --
> Johan Andrén
> Akka Team, Lightbend Inc.
>

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


Re: [akka-user] akka.actor.PreRestartException Happening whenever there is restart

2016-03-11 Thread Akka Team
Option.get does not return null for an empty option, it throws an exception.

--
Johan Andrén
Akka Team, Lightbend Inc.

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


Re: [akka-user] akka.actor.PreRestartException Happening whenever there is restart

2016-03-11 Thread Biniam Asnake
Here is my implementation in AbstractActor.

AbstractActor extends UntypedActor and all other actor classes extend this 
AbstractActor class.

I am using Groovy language and `?.` operator is a null check (e.g. 
message?.get()?.toString() means if message is not null, get the message. 
If get is not null, cast it to String).

I override the preRestart() method and I am resending the message to Actor.

What am I doing wrong?

abstract class AbstractActor extends UntypedActor implements Serializable {

private final static Logger log = 
LoggerFactory.getLogger(AbstractActor.class)

@Override
void preRestart (Throwable reason, Option message) throws Exception 
{

log.error("preRestart called at ${self()} with message: 
${message?.get()?.toString()}. Error: ${reason?.message}.")

if(message && message?.get()) {

self().tell(message?.get(), sender())
log.error("preRestart: Resending message class: 
'${message.getClass()}' to ${self()}.")
}

super.preRestart(reason, message)
}

}




On Friday, March 11, 2016 at 2:37:02 PM UTC+1, Akka Team wrote:
>
> If you are doing .get on the message in your preRestart: that is not 
> safe, the actor might restart for reasons not being a message and then the 
> option will be empty. In general just .get:ing an option is an 
> antipattern, someone made it an option because it can be empty so you need 
> to deal with that.
>
> --
> Johan Andrén
> Akka Team, Lightbend Inc.
>

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


Re: [akka-user] akka.actor.PreRestartException Happening whenever there is restart

2016-03-11 Thread Akka Team
If you are doing .get on the message in your preRestart: that is not safe,
the actor might restart for reasons not being a message and then the option
will be empty. In general just .get:ing an option is an antipattern,
someone made it an option because it can be empty so you need to deal with
that.

--
Johan Andrén
Akka Team, Lightbend Inc.

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


Re: [akka-user] akka.actor.PreRestartException Happening whenever there is restart

2016-03-11 Thread Roland Kuhn
Hi Biniam,

from the stack trace it is pretty obvious that you should look at 
AbstractActor.groovy—which is not an Akka source file.

Regards,

Roland

> 11 mar 2016 kl. 12:28 skrev Biniam Asnake :
> 
> Hello everyone,
> 
> Please guide me in the right direction to solve this issue.
> 
> On Thursday, March 10, 2016 at 10:21:26 AM UTC+1, Biniam Asnake wrote:
> Hello,
> 
> I always get this exception whenever the actor restarts and send the message 
> again to the actor.
> 
> Why does it happen and how do I solve it?
> 
> Thanks.
> 
> akka.actor.PreRestartException: exception in preRestart(class 
> com.google.api.ads.adwords.axis.v201509.cm.ApiException, None)
> at 
> akka.actor.dungeon.FaultHandling$$anonfun$1.apply(FaultHandling.scala:69)
> at 
> akka.actor.dungeon.FaultHandling$$anonfun$1.apply(FaultHandling.scala:68)
> at 
> akka.actor.dungeon.FaultHandling$$anonfun$handleNonFatalOrInterruptedException$1.applyOrElse(FaultHandling.scala:302)
> at 
> akka.actor.dungeon.FaultHandling$$anonfun$handleNonFatalOrInterruptedException$1.applyOrElse(FaultHandling.scala:297)
> at 
> scala.runtime.AbstractPartialFunction.apply(AbstractPartialFunction.scala:36)
> at 
> akka.actor.dungeon.FaultHandling$class.faultRecreate(FaultHandling.scala:68)
> at akka.actor.ActorCell.faultRecreate(ActorCell.scala:369)
> at akka.actor.ActorCell.invokeAll$1_aroundBody2(ActorCell.scala:459)
> at akka.actor.ActorCell$AjcClosure3.run(ActorCell.scala:1)
> at 
> org.aspectj.runtime.reflect.JoinPointImpl.proceed(JoinPointImpl.java:149)
> at 
> akka.kamon.instrumentation.ActorSystemMessageInstrumentation$$anonfun$aroundSystemMessageInvoke$1.apply(ActorSystemMessageInstrumentation.scala:34)
> at kamon.trace.Tracer$.withContext(TracerModule.scala:57)
> at 
> akka.kamon.instrumentation.ActorSystemMessageInstrumentation.aroundSystemMessageInvoke(ActorSystemMessageInstrumentation.scala:34)
> at akka.actor.ActorCell.invokeAll$1(ActorCell.scala:1)
> at akka.actor.ActorCell.systemInvoke(ActorCell.scala:478)
> at akka.dispatch.Mailbox.processAllSystemMessages(Mailbox.scala:279)
> at akka.dispatch.Mailbox.run(Mailbox.scala:220)
> at akka.dispatch.Mailbox.exec(Mailbox.scala:231)
> at 
> scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
> at 
> scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.pollAndExecAll(ForkJoinPool.java:1253)
> at 
> scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1346)
> at 
> scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
> at 
> scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
> Caused by: java.util.NoSuchElementException: None.get
> at scala.None$.get(Option.scala:347)
> at 
> com.bonial.megan.execution.actors.AbstractActor.preRestart(AbstractActor.groovy:52)
> at akka.actor.Actor$class.aroundPreRestart(Actor.scala:480)
> at akka.actor.UntypedActor.aroundPreRestart(UntypedActor.scala:97)  
> at 
> akka.actor.dungeon.FaultHandling$class.faultRecreate(FaultHandling.scala:67)
> ... 17 more
> 2016-03-07 15:05:42,886 [AdwordsJobExecutor-akka.actor.default-dispatcher-99] 
> ERROR
> 
> com.bonial.megan.execution.actors.bulkCpcChange.mutate.BulkCpcBidChangeActor.apply$mcV$sp([...])
>  at Line 66
> None.get
> 
> 
> 
> 
> -- 
> >> Read the docs: http://akka.io/docs/ 
> >> Check the FAQ: 
> >> http://doc.akka.io/docs/akka/current/additional/faq.html 
> >> 
> >> Search the archives: https://groups.google.com/group/akka-user 
> >> 
> --- 
> You received this message because you are subscribed to the Google Groups 
> "Akka User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to akka-user+unsubscr...@googlegroups.com 
> .
> To post to this group, send email to akka-user@googlegroups.com 
> .
> Visit this group at https://groups.google.com/group/akka-user 
> .
> For more options, visit https://groups.google.com/d/optout 
> .



Dr. Roland Kuhn
Akka Tech Lead
Typesafe  – Reactive apps on the JVM.
twitter: @rolandkuhn
 

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from t

[akka-user] akka.actor.PreRestartException Happening whenever there is restart

2016-03-10 Thread Biniam Asnake
Hello,

I always get this exception whenever the actor restarts and send the 
message again to the actor.

Why does it happen and how do I solve it?

Thanks.

akka.actor.PreRestartException: exception in preRestart(class 
com.google.api.ads.adwords.axis.v201509.cm.ApiException, None)
at 
akka.actor.dungeon.FaultHandling$$anonfun$1.apply(FaultHandling.scala:69)
at 
akka.actor.dungeon.FaultHandling$$anonfun$1.apply(FaultHandling.scala:68)
at 
akka.actor.dungeon.FaultHandling$$anonfun$handleNonFatalOrInterruptedException$1.applyOrElse(FaultHandling.scala:302)
at 
akka.actor.dungeon.FaultHandling$$anonfun$handleNonFatalOrInterruptedException$1.applyOrElse(FaultHandling.scala:297)
at 
scala.runtime.AbstractPartialFunction.apply(AbstractPartialFunction.scala:36)
at 
akka.actor.dungeon.FaultHandling$class.faultRecreate(FaultHandling.scala:68)
at akka.actor.ActorCell.faultRecreate(ActorCell.scala:369)
at akka.actor.ActorCell.invokeAll$1_aroundBody2(ActorCell.scala:459)
at akka.actor.ActorCell$AjcClosure3.run(ActorCell.scala:1)
at 
org.aspectj.runtime.reflect.JoinPointImpl.proceed(JoinPointImpl.java:149)
at 
akka.kamon.instrumentation.ActorSystemMessageInstrumentation$$anonfun$aroundSystemMessageInvoke$1.apply(ActorSystemMessageInstrumentation.scala:34)
at kamon.trace.Tracer$.withContext(TracerModule.scala:57)
at 
akka.kamon.instrumentation.ActorSystemMessageInstrumentation.aroundSystemMessageInvoke(ActorSystemMessageInstrumentation.scala:34)
at akka.actor.ActorCell.invokeAll$1(ActorCell.scala:1)
at akka.actor.ActorCell.systemInvoke(ActorCell.scala:478)
at akka.dispatch.Mailbox.processAllSystemMessages(Mailbox.scala:279)
at akka.dispatch.Mailbox.run(Mailbox.scala:220)
at akka.dispatch.Mailbox.exec(Mailbox.scala:231)
at 
scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
at 
scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.pollAndExecAll(ForkJoinPool.java:1253)
at 
scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1346)
at 
scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
at 
scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
Caused by: java.util.NoSuchElementException: None.get
at scala.None$.get(Option.scala:347)
at 
com.bonial.megan.execution.actors.AbstractActor.preRestart(AbstractActor.groovy:52)
at akka.actor.Actor$class.aroundPreRestart(Actor.scala:480)
at akka.actor.UntypedActor.aroundPreRestart(UntypedActor.scala:97)  
at 
akka.actor.dungeon.FaultHandling$class.faultRecreate(FaultHandling.scala:67)
... 17 more
2016-03-07 15:05:42,886 
[AdwordsJobExecutor-akka.actor.default-dispatcher-99] ERROR

com.bonial.megan.execution.actors.bulkCpcChange.mutate.BulkCpcBidChangeActor.apply$mcV$sp([...])
 
at Line 66
None.get



-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.