2 Replies Latest reply on Apr 18, 2010 4:05 AM by Priyanka Sharma

    Problem of jboss server starting on connection failover

    Priyanka Sharma Newbie



      I am working on failover condition of a datasource.


      When a request comes, if primary datasource is not available then the request should go to the secondary datasource without restarting the jboss server.


      I have added ha-local-tx-datasource in *-ds.xml



      •   <jndi-name>HADefaultDS</jndi-name>        
      •    <!-- list of connection URLs -->        
      •    <connection-url>jdbc:oracle:thin:@oraclehost:1521:SID|jdbc:oracle:thin:@oraclehost:1521:SID2         
      •    </connection-url>         
      •    <url-delimiter>|</url-delimiter>
      • </ha-local-tx-datasource>

      • Problem m facing is, i have to restart the jboss server in case of 1st datasource connection fails. I want to rid of manual server startup.
      • Please suggest me how to send the request on secondary datasource transparently.         



      Thanks in advance.

        • 1. Re: Problem of jboss server starting on connection failover
          Samarjit Chakraborty Newbie

          Dear Priyanka,


          I've got this reference from http://community.jboss.org/wiki/JBossJCADatabaseFailover


          In JBoss v5.0.x or greater <ha-local-tx-datasource> elements are no longer supported. Instead of that you can put the <connection-url> separated by delimiters in your main <local-tx-datasource> element inside *-ds.xml. Even <url-delimiter> can be included inside.


          I've tested it using this configuration:


                <!-- The jndi name of the DataSource, it is prefixed with java:/ -->
                <!-- Datasources are not available outside the virtual machine -->
                <!-- The driver class -->
                <!-- The login and password -->
                <!-- The maximum connections in a pool/sub-pool -->
                <!-- The time before an unused connection is destroyed -->
                <!-- Whether to check all statements are closed when the connection is returned to the pool,
                     this is a debugging feature that should be turned off in production -->
                <!-- Benefits from prepared statement caching -->
                <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->


          And it is working. When i stopped the instance of database representing "url1" JBoss automatically bound the JNDI name to "url2". Please check it out.


          Let me know whether you succeeded or not.


          Best of luck



          • 2. Re: Problem of jboss server starting on connection failover
            Priyanka Sharma Newbie

            No, i m using JBOSS eap 4.0. So, here the code of ha datasource is working but i need to restart the jboss server for switching onto secondary datasource if primary fails. If I don't restart the server then the connection gets closed when 1st datasource fails. It gives the error of Connection not open.


            Please help me out if you have worked on the failover condition. Thanks a lot for ur reply.