Thursday, September 29, 2011

JBoss Database Failover & High Availability Datasource

Share it Please

A high availability Datasource is an abstraction over a list of data sources that provide failover processing between lists of data sources. In Weblogic, we can configure multi-pool which provides us the same functionality.

The configuration of Multi pool sort of thing in JBoss is done in a different way. In Weblogic, we configure multiple data sources and configure them in one multi pool such that when a Datasource fails to connect, the servers use the second Datasource to get a connection.

In JBoss, we don’t need to configure multiple data sources rather we configure the URL’s in one Datasource file like,

<?xml version="1.0" encoding="UTF-8"?>







The main points to check are the

<connection-url>|</connection-url> : Url separated by a delimiter “|”

<url-delimiter>|</url-delimiter> :  Holder used as a delimiter

Now, we can test the Datasource from the admin-console. If we need to test the fail over capabilities, then modify the one of the URL and test the connection. You can see an error on command console and connection will be obtained from second URL.

Note: we can use connection.getMetaData().getUrl() , to find which URL is used to get the connection. In this way we can make sure the fail over is working.

More articles to come. Happy coding…

1 comment :

  1. thanks... nice post. for more java examples, visit site