5 Replies Latest reply on Nov 11, 2009 7:44 AM by Vicky Kak

    Datasource Failover Notification

    Mayank Mittal Novice

      my Environment
      --------------------

      2 Postgres Servers v 8.3.1
      1 JBoss AS 4.2.3

      Setup
      ------

      In my postgress-ds.xml, I've configured the datasource as HA-XA-datasource to use both servers.

      Problem
      ---------
      Now I want to get notified when one data base is down to intimate the clients that database is down.


      Is there any way to listen any such JMX notification that notifies about the database failover

        • 1. Re: Datasource Failover Notification
          bb bb Master

          Hy!

          Could you attach your postgress-ds.xml.

          thx.

          • 2. Re: Datasource Failover Notification
            Mayank Mittal Novice

             

            
            <datasources>
             <ha-xa-datasource>
             <jndi-name>PostgresDS</jndi-name>
             <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
             <xa-datasource-property name="ServerName">${data.source}</xa-datasource-property>
             <xa-datasource-property name="PortNumber">5432</xa-datasource-property>
             <xa-datasource-property name="DatabaseName">smd</xa-datasource-property>
             <!--xa-datasource-property name="Ssl">false</xa-datasource-property-->
             <xa-datasource-property name="User">systemmgr</xa-datasource-property>
             <xa-datasource-property name="Password">cms10</xa-datasource-property>
             <url-property>ServerName</url-property>
             <url-delimiter>,</url-delimiter>
            
             <track-connection-by-tx/>
            
             <metadata>
             <type-mapping>PostgreSQL 8.0</type-mapping>
             </metadata>
            
             <prepared-statement-cache-size>32</prepared-statement-cache-size>
             <min-pool-size>5</min-pool-size>
             <max-pool-size>20</max-pool-size>
             <max-idle-timeout>0</max-idle-timeout>
             <blocking-timeout-millis>30000</blocking-timeout-millis>
             <idle-timeout-minutes>0</idle-timeout-minutes>
             <track-statements>true</track-statements>
             <check-valid-connection-sql>select version()</check-valid-connection-sql>
             </ha-xa-datasource>
            
             <ha-xa-datasource>
             <jndi-name>ArgusDS</jndi-name>
             <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
             <xa-datasource-property name="ServerName">${data.source}</xa-datasource-property>
             <xa-datasource-property name="PortNumber">5432</xa-datasource-property>
             <xa-datasource-property name="DatabaseName">smd</xa-datasource-property>
             <!--xa-datasource-property name="Ssl">false</xa-datasource-property-->
             <xa-datasource-property name="User">systemmgr</xa-datasource-property>
             <xa-datasource-property name="Password">cms10</xa-datasource-property>
             <url-property>ServerName</url-property>
             <url-delimiter>,</url-delimiter>
            
             <track-connection-by-tx/>
            
             <metadata>
             <type-mapping>PostgreSQL 8.0</type-mapping>
             </metadata>
            
             <prepared-statement-cache-size>32</prepared-statement-cache-size>
             <min-pool-size>5</min-pool-size>
             <max-pool-size>20</max-pool-size>
             <max-idle-timeout>0</max-idle-timeout>
             <blocking-timeout-millis>30000</blocking-timeout-millis>
             <idle-timeout-minutes>0</idle-timeout-minutes>
             <track-statements>true</track-statements>
             <check-valid-connection-sql>select version()</check-valid-connection-sql>
             </ha-xa-datasource>
            
             <ha-xa-datasource>
             <jndi-name>DefaultDS</jndi-name>
             <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
             <xa-datasource-property name="ServerName">${data.source}</xa-datasource-property>
             <xa-datasource-property name="PortNumber">5432</xa-datasource-property>
             <xa-datasource-property name="DatabaseName">jms</xa-datasource-property>
             <!--xa-datasource-property name="Ssl">false</xa-datasource-property-->
             <xa-datasource-property name="User">systemmgr</xa-datasource-property>
             <xa-datasource-property name="Password">cms10</xa-datasource-property>
             <url-property>ServerName</url-property>
             <url-delimiter>,</url-delimiter>
            
             <track-connection-by-tx/>
            
             <metadata>
             <type-mapping>PostgreSQL 8.0</type-mapping>
             </metadata>
            
             <prepared-statement-cache-size>32</prepared-statement-cache-size>
             <min-pool-size>5</min-pool-size>
             <max-pool-size>20</max-pool-size>
             <max-idle-timeout>0</max-idle-timeout>
             <blocking-timeout-millis>30000</blocking-timeout-millis>
             <idle-timeout-minutes>0</idle-timeout-minutes>
             <track-statements>true</track-statements>
             <check-valid-connection-sql>select version()</check-valid-connection-sql>
             </ha-xa-datasource>
            
             <ha-xa-datasource>
             <jndi-name>BMSDS</jndi-name>
             <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
             <xa-datasource-property name="ServerName">${data.source}</xa-datasource-property>
             <xa-datasource-property name="PortNumber">5432</xa-datasource-property>
             <xa-datasource-property name="DatabaseName">bms</xa-datasource-property>
             <xa-datasource-property name="User">systemmgr</xa-datasource-property>
             <xa-datasource-property name="Password">cms10</xa-datasource-property>
             <url-property>ServerName</url-property>
             <url-delimiter>,</url-delimiter>
            
             <track-connection-by-tx/>
            
             <metadata>
             <type-mapping>PostgreSQL 8.0</type-mapping>
             </metadata>
            
             <prepared-statement-cache-size>32</prepared-statement-cache-size>
             <min-pool-size>5</min-pool-size>
             <max-pool-size>20</max-pool-size>
             <max-idle-timeout>0</max-idle-timeout>
             <blocking-timeout-millis>30000</blocking-timeout-millis>
             <idle-timeout-minutes>0</idle-timeout-minutes>
             <track-statements>true</track-statements>
             <check-valid-connection-sql>select version()</check-valid-connection-sql>
             </ha-xa-datasource>
            
            </datasources>
            
            
            


            • 3. Re: Datasource Failover Notification
              bb bb Master

              How can you use ha-xa datasource service, these datasources are differents.

              • 4. Re: Datasource Failover Notification
                bb bb Master

                I would like to create the same topolgy with postgres datasources:
                http://www.mastertheboss.com/en/jboss-application-server/82-jboss-datasource-ha.html

                • 5. Re: Datasource Failover Notification
                  Vicky Kak Master

                   

                  "mayankmit2002" wrote:

                  In my postgress-ds.xml, I've configured the datasource as HA-XA-datasource to use both servers.

                  The attached -ds.xml contains incorrect configuration about ha datasource !

                  "mayankmit2002" wrote:

                  Problem
                  ---------
                  Now I want to get notified when one data base is down to intimate the clients that database is down.

                  I don't know what exactly you are trying to do here.
                  You can write a custom MBean which will monitor the working of the datasource,getting the JMX notification when the DB goes down would not be possible without the change in JCA code.
                  With Jboss5 you can probabily make the JMX notification via custom UrlSelectStrategy implementation.