0 Replies Latest reply on Sep 24, 2013 6:34 PM by toriacht

    Amazon RDS Master Slave configuration for JEE 6

    toriacht

      I have a JEE 6 application deployed on JBoss 7.1 that currently connects to a standalone MySQL instance. It connects to a localhost MySQL using a standard datasource.xml (deployed on app server) and persistence (deployed in application .war), example below.

      I wish to configure my application now to talk to an  Amazon RDS MySql instance running in master-slave mode. Recommended configuration is  to write only to the master and read only from the slaves. I presume this is achieved by datasource.xml edits but how exactly should I achieve this? Is there a sample -ds file available etc?

       

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

      <datasources xmlns="http://www.jboss.org/ironjacamar/schema">

       

        <!-- to be copied to the deployments folder before the war is deployed but

        after the mysql connector jar is copied to the deployments folder -->

        <datasource jndi-name="java:jboss/datasources/mydb"

        pool-name="mypool">

        <connection-url>jdbc:mysql://localhost:3306/mydb_test</connection-url>

        <driver>mysql-connector-java-5.1.22-bin.jar</driver>

        <pool>

        <max-pool-size>30</max-pool-size>

        </pool>

        <security>

        <user-name>user</user-name>

        <password>pass</password>

        </security>

        </datasource>

      </datasources>

       

       

      Perhaps I define multiple datasources in one xml file,  slave datasources are defined as readOnly and one master datasource is configured as a standard connection? If so does the container then handle sending writes and reads to the appropriate datasource?

      Thanks,

      T