Is there a way to restart Tomcat Connection Pool at runtime?

My business is as follows:

  • I need to support a server with Tomcat (6) as a web server that has a bunch of webapps on it. These webapps are supported by others. Our server has a connection to another DB server of the department, which has the information that our web clients must display. Without the right merge strategy, our server soon became a disaster.

  • Now that I am introducing Pooling for everyone (I chose BoneCP-0.7), we are going to create a single pool that will be on Tomcat's global JNDI content and let everyone get a connection from it. This should solve the problem, I think.

My concern: how can I fully control this pool? I have some requirements:

  • I want to reload the DataSource configuration at runtime, both manually and programmatically (try connecting to the backup server at the right time)

  • Change the number of connections (min, max, idle connections) that may change from time to time

  • Keep Tomcat Alive Preferred

  • I intend to create a notification system that uses JMX to connect and receive information, as well as a button to reload the pool (I know that the whole merge strategy has some kind of recovery, but another database server is periodically triggered, so manually reloading connections is preferable).

I am thinking of some possible solutions:

  • Notify Tomcat about the resumption of the global JNDI context
  • Tell Tomcat to restart the DataSource
  • Tell BoneCP to restart the pool and, if necessary, recreate the connections.
  • Restart Tomcat itself

My question is:

  • Can I safely implement the above solutions without affecting Tomcat (and other web applications)?
  • Should I do this at all? (Just bring Tomcat back, I think)
+4
source share
1 answer

(Why does someone choose BoneCP? Every question I have ever heard about this is related to BoneCP, resolved by switching the poster to another CP, and everything works. BoneCP is not even in version 1.0. The next big thing. It just hasn’t come yet .)

Tomcat comes with support for Apache commons-dbcp and its own Tomcat Tomcat pool: just configure the JNDI connection pool according to Tomcat docs and you will be disconnected.

Unfortunately, Tomcat does not currently support reloading a DataSource at runtime. You can change properties through JMX, but the changes are not affected. You can also close the pool, but you just get the indoor pool, which is then useless.

Writing the extension in Tomcat bugzilla is likely to be fine.

+2
source

All Articles