--
>>>>>>>>>> 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+...@googlegroups.com.
To post to this group, send email to akka...@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.
scheduleOnce(logger.debug("1 currentTimeMillis {}", System.currentTimeMillis()), FiniteDuration(100, MICROSECONDS))
scheduleOnce(logger.debug("2 currentTimeMillis {}", System.currentTimeMillis()), FiniteDuration(100, MILLISECONDS))
scheduleOnce(logger.debug("3 currentTimeMillis {}", System.currentTimeMillis()), FiniteDuration(100, SECONDS))
scheduleOnce(logger.debug("4 currentTimeMillis {}", System.currentTimeMillis()), FiniteDuration(100, MINUTES))
scheduleOnce(logger.debug("5 currentTimeMillis {}", System.currentTimeMillis()), FiniteDuration(100, DAYS))
Produced
2016-08-26 09:04:15,111 DEBUG ... akka.actor.default-dispatcher-3 - 1 currentTimeMillis 1472227455110
2016-08-26 09:04:15,115 DEBUG ... akka.actor.default-dispatcher-3 - 2 currentTimeMillis 1472227455114
2016-08-26 09:04:15,115 DEBUG ... akka.actor.default-dispatcher-3 - 3 currentTimeMillis 1472227455114
2016-08-26 09:04:15,116 DEBUG ... akka.actor.default-dispatcher-3 - 4 currentTimeMillis 1472227455114
2016-08-26 09:04:15,116 DEBUG ... akka.actor.default-dispatcher-3 - 5 currentTimeMillis 1472227455114
Akka version 2.4.9
Gary
Thanks Konrad, but I posted because I tried scheduleOnce and got no delayscheduleOnce(logger.debug("1 currentTimeMillis {}", System.currentTimeMillis()), FiniteDuration(100, MICROSECONDS))
scheduleOnce(logger.debug("2 currentTimeMillis {}", System.currentTimeMillis()), FiniteDuration(100, MILLISECONDS))
scheduleOnce(logger.debug("3 currentTimeMillis {}", System.currentTimeMillis()), FiniteDuration(100, SECONDS))
scheduleOnce(logger.debug("4 currentTimeMillis {}", System.currentTimeMillis()), FiniteDuration(100, MINUTES))
scheduleOnce(logger.debug("5 currentTimeMillis {}", System.currentTimeMillis()), FiniteDuration(100, DAYS))
Produced
2016-08-26 09:04:15,111 DEBUG ... akka.actor.default-dispatcher-3 - 1 currentTimeMillis 1472227455110
2016-08-26 09:04:15,115 DEBUG ... akka.actor.default-dispatcher-3 - 2 currentTimeMillis 1472227455114
2016-08-26 09:04:15,115 DEBUG ... akka.actor.default-dispatcher-3 - 3 currentTimeMillis 1472227455114
2016-08-26 09:04:15,116 DEBUG ... akka.actor.default-dispatcher-3 - 4 currentTimeMillis 1472227455114
2016-08-26 09:04:15,116 DEBUG ... akka.actor.default-dispatcher-3 - 5 currentTimeMillis 1472227455114
Akka version 2.4.9
Gary
--
>>>>>>>>>> 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+unsubscribe@googlegroups.com.
override def createLogic(inheritedAttributes: Attributes): GraphStageLogic = {
new TimerGraphStageLogic(shape) {
private def decider = inheritedAttributes.get[SupervisionStrategy].map(_.decider).
getOrElse(Supervision.stoppingDecider)
var retries = 1
var duration = 100
def myHandler(): Unit = {
try {
if(testException != null) throw testException
if(iter.hasNext) {
push(out, iter.next())
}
} catch {
case NonFatal(e) => decider(e) match {
case Supervision.Stop => {
failStage(e)
}
case Supervision.Resume => {
if(retries > 0) {
logger.debug("before scheduleOnce retries {} duration {}", retries, duration)
scheduleOnce(None, FiniteDuration(duration, MILLISECONDS))
} else {
failStage(e) // too many retries
}
}
}
}
}
setHandler(out, new OutHandler {
override def onPull(): Unit = {
myHandler()
}
})
override protected def onTimer(timerKey: Any): Unit = {
retries -= 1
duration *= 2
myHandler()
}
}
}
Sorry, my onTimer() doesn't fire.
It looks like all I need to do is 1. use TimerGraphStageLogic 2. call scheduleOnce 3. override onTimer. I am misusing Resume for retries but I've tried scheduleOnce in other places and it still doesn't fire. Here's an example,
--
I'd probably start by implementing the behavior through the built in combinators before venturing into creating custom stages.
--
Cheers,
√
Is this a Source? You omitted the shape... Anyway, it might be that your stage is shut down earlier than the timer for some reason (for example downstream cancelled). Override postStop() and print something there to see.
-Endre