Sorry I posted this in github issues, but it seems like no one is maintaining it.Hi,
What I did is,
1. boot up my application.
2.Then turn off my mysql.
3. Send a request to my webservice that would trigger a transaction. (Simple byId)
I am using:
val storage = new PooledJdbcRelationalStorage { val jdbcDriver = "com.mysql.jdbc.Driver" }
This is my code for catching the exception and retrying.
class EntityManager(implicit val ctx: ActivateContext) extends Actor { def receive ={ case message => doAction(Find[SampleEntity]("ID1"),0 ,sender) } def doAction(a:Action,count:Int, sender:ActorRef):Unit ={ a.eval onComplete{ case Success(message) => log.debug("SUCCESS " +message) message match{ case Some(data) => sender ! data case None => sender ! Fail } case Failure(exception) => exception match{ case e:JdbcStatementException => log.debug("FAIL" + e) if(count >= 2){ sender ! Fail }else{ doAction(a,count + 1,sender) } case e:java.sql.SQLException => log.debug("FAIL " + e) if(count >= 2){ sender ! Fail }else{ doAction(a,count + 1,sender) } } } case class Find[E <: BaseEntity: Manifest](id: E#ID) extends Action { def eval(implicit ctx: ActivateContext, exec: ExecutionContext): Future[Option[EntityMap[E]]] = { import ctx._ asyncTransactional { val entity = transactional { byId[E](id)} val map = transactional { entity.map(_.toMap) } map } } } }
Here is the results (this is from my actual app name of package is changed)
2015-04-29 14:57:07,962 [DEBUG] c.o.m.managers.EntityManager ForkJoinPool-2-worker-5 - FAIL java.sql.SQLTimeoutException: Timeout after 29999ms of waiting for a connection. 2015-04-29 14:57:07,985 [DEBUG] c.o.m.managers.EntityManager ForkJoinPool-2-worker-5 - SUCCESS SampleEntity("ID1",null)
As you could see in the logs , after failing it tried that same transaction again. It succeded (MYSQL DB/SERVICE is down). The resulting entity that the retry find got is:
SampleEntity("ID1",null)
This id/entity entry doesn't even exist in my db.
This is the model of the Entity
SampleEntity(name:String) extends Entity
EDIT:
Temporary solution
reinitializeContext
But I am worried for multiple concurrent request that would try to reinitializeContext. I remember experiencing a exception when doing reinitializeContext alot of times.
Anyone know disadvantages of concurrent reinitializeContext
Related github issue:
--
You received this message because you are subscribed to the Google Groups "Activate Persistence Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to activate-persist...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to activate-persistence+unsub...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to activate-persist...@googlegroups.com.