java - Is it safe or advisable to re-enqueue a Runnable with the same Executor if a problem occurs and I want to retry? -
i wrote code in runnable's run()
method:
try { dbconnection = myapp.datasource.getconnection(); } catch (sqlexception e) { logger.log(level.severe, "could not obtain db connection! re-enqueuing task. message: " + e.getmessage(), e); myapp.executor.execute(this); return; }
as can see, if task can't obtain db connection, should re-enqueue itself, same queue in before ran.
i'm thinking probably safe, feels funny, , want make sure there aren't gotchyas i'm missing.
thanks!
this fine far executor goes.
but keep in mind failures may occur pretty quickly, , executor may re-run code quickly. can result in burning lot of cpu no results.
build in forced retry delays , maximum loop counts.
Comments
Post a Comment