You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-dev@db.apache.org by Keith Frampton <ke...@trapezegroup.com> on 2015/10/27 13:29:56 UTC

MySQL read replication load balancing through torque

Hi,
We have software that is using Torque to directly connect to database servers.  We now have a requirement to use a master / slave MySQL set up and our client are reluctant to put a load balancer in the way.  I've been trying to establish if it's possible through Torque to use the MySQL read replication driver.

As Google turned up limited information, I couldn't find anything on the mailing list (searched via http://httpd.markmail.org) and a list of supported drivers for Torque did not show the MySQL read replication driver, this email is the last ditch effort to find an answer.

The connection String (torque.dsfactory.[db].datasource.url) I've been setting as  jdbc:mysql:replication://[master]:3306,[slave]:3306/[db].
I've tried setting the driver to com.mysql.jdbc.ReplicationDriver
I've changed the factory from JndiDataSourceFactory to SharedPoolDataSourceFactory.
I believe the adapter was incorrect as it was set to org.gjt.mm.mysql.Driver so I've changed that to MySQL and also tried changing it to the DBMM class.

Unfortunately it's difficult for me to give code exerts as it's configured through a configuration module into a bean that assigns the properties from a mix of static Strings and values from the config module.

The 2 issues I hit for every combination of changes I make are either a null pointer in org.apache.torque.adapter.DBFactory in the function create(String key, String className) for the adapterClass (this is what lead me to the conclusion the adapter was incorrect as the original jira suggested it would be as simple as changing the adapter from org.gjt.mm.mysql.Driver to com.mysql.jdbc.ReplicationDriver.

Or a SQL exception stating that I must specify at least one slave, however, everything I can see suggests the connection string is correct for a read replication connection.

Any help would be greatly appreciated.

Many thanks for your time,
Keith.

Keith Frampton
Trapeze Group