Monday, November 16, 2009

Geronimo Load Balancing database deployment

Recently I had the need to deploy a new datasource in Apache Geronimo, usually this would be a five minutes process that will just require a quick update of the deployment plan similar to this one:


 <connector xmlns="http://geronimo.apache.org/xml/ns/j2ee/connector-1.2">  
   <dep:environment xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.2">  
     <dep:moduleId>  
       <dep:groupId>console.dbpool</dep:groupId>  
       <dep:artifactId>jdbc.myapp.mydb</dep:artifactId>  
       <dep:version>1.0</dep:version>  
       <dep:type>rar</dep:type>  
     </dep:moduleId>  
     <dep:dependencies>  
       <dep:dependency>  
         <dep:groupId>oracle</dep:groupId>  
         <dep:artifactId>ojdbc5</dep:artifactId>  
         <dep:version>11.1.0.6.0</dep:version>  
         <dep:type>jar</dep:type>  
       </dep:dependency>  
     </dep:dependencies>  
   </dep:environment>  
   <resourceadapter>  
     <outbound-resourceadapter>  
       <connection-definition>  
         <connectionfactory-interface>javax.sql.DataSource</connectionfactory-interface>  
         <connectiondefinition-instance>  
           <name>jdbc.myapp.mydb</name>  
                          <config-property-setting name="Password">mypass</config-property-setting>  
           <config-property-setting name="UserName">myuser</config-property-setting>  
                          <config-property-setting name="DatabaseName">DB113</config-property-setting>  
                          <config-property-setting name="DataSourceName">mydb</config-property-setting>  
                          <config-property-setting name="ServerName">myserver</config-property-setting>  
                          <config-property-setting name="PortNumber">1521</config-property-setting>  
                          <config-property-setting name="DriverType">thin</config-property-setting>  
           <connectionmanager>  
             <xa-transaction>  
               <transaction-caching/>  
             </xa-transaction>  
             <single-pool>  
               <max-size>10</max-size>  
               <min-size>0</min-size>  
                                    <blocking-timeout-milliseconds>5</blocking-timeout-milliseconds>  
               <idle-timeout-minutes>1</idle-timeout-minutes>  
               <match-one/>  
             </single-pool>  
           </connectionmanager>  
         </connectiondefinition-instance>  
       </connection-definition>  
     </outbound-resourceadapter>  
   </resourceadapter>  
 </connector>  


But in this case I needed to deploy a database with load balancing, since I couldn't find this info online I thought about sharing with everyone the deployment plan that worked for me, it is similar to the previous one and the difference is in the "connectiondefinition-instance" element:


         <connectiondefinition-instance>  
           <name>jdbc.rf2h.mydb</name>  
           <config-property-setting name="Driver">oracle.jdbc.OracleDriver</config-property-setting>  
           <config-property-setting name="Password">mypass</config-property-setting>  
           <config-property-setting name="UserName">myuser</config-property-setting>  
           <config-property-setting name="ConnectionURL">jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS = (PROTOCOL = TCP)(HOST = 192.8.231.8)(PORT = 1521))(ADDRESS = (PROTOCOL = TCP)(HOST = 192.8.231.9)(PORT = 1521))(LOAD_BALANCE = yes)(CONNECT_DATA = (SERVER = DEDICATED)(SERVICE_NAME = db313))  
                          </config-property-setting>  
                          <config-property-setting name="CommitBeforeAutocommit">true</config-property-setting>  
           <connectionmanager>  
             <local-transaction/>  
             <single-pool>  
               <max-size>5</max-size>  
               <min-size>1</min-size>  
               <blocking-timeout-milliseconds>30</blocking-timeout-milliseconds>  
               <idle-timeout-minutes>1</idle-timeout-minutes>  
               <match-one/>  
             </single-pool>  
           </connectionmanager>  
         </connectiondefinition-instance>                      


As you can see, all the info about the load balance is in this "ConnectionURL" property, that's it, I hope this helps ;)

PS: for this deployment I used the following library: geronimo-tomcat6-javaee5-2.1.2\repository\org\tranql\tranql-connector-ra\1.4\tranql-connector-ra-1.4.rar
blog comments powered by Disqus