Announcement Announcement Module
Collapse
No announcement yet.
Retry after network interruptions Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Retry after network interruptions

    My project uses HibernateDAOSupport class to perform DAO operations and transactions are handled with help of JTATransactionManager from the service level. The application is hosted on cloud and there seems to be lots of network disruptions b/w that and the DB. So many of the transactions are throwing Connection closed error.
    Team is analysing ways to safely retry the operation two or more times, when this happens.
    As I understand, we need a new session which each retry attempt, so it can fetch a new connection from the pool.
    One way to do this is put an interceptor before the transaction manager and retry the whole operation from this level after catching the appropriate exception.
    This however will impose performance issues as the service will do other computations and interaction with other services (outside the transaction).
    So is it possible to perform retry at a lower level say DAO level using DAOSupportClass? I don't think we can put a interceptor before the DAOSupportClass since we can't write an interface for it.
    Please share ideas that could solve this problem the right way.

  • #2
    As of now, I wrote an interceptor around my DAO that will do the below during an ConnectionException
    > dao().getHibernateTemplate().getSessionFactory().g etCurrentSession().disconnect()
    > dao().getHibernateTemplate().getSessionFactory().g etCurrentSession().reconnect(Connection connection)
    where connection is picked direclty using the Datasource object in XML Bean factory. I tried several scenarios by disconnecting and reconnecting to the network and this seems to be working. But is this a good approach? Does this have any side effect?

    Comment

    Working...
    X