Removing HypersonicHypersonic is a great database for testing an application, but it isn't production ready. In Chapter 4, you saw how to switch to another database. If you aren't using Hypersonic, you can remove the entire service. Hypersonic doesn't listen for connections from the outside world unless you ask it to, so you don't need to worry about securing it. However, you might not want an extra relational database hanging around in memory. It's fairly lightweight, but you'll probably be better off just getting rid of it. How do I do that?The hsqldb-ds.xml file not only configures the Hypersonic datasources, but also it has the MBeans that control the entire embedded database service. Removing this file will remove all traces of Hypersonic. It sounds trivial, and it would be except that several other services depend on Hypersonic. We'll go through the changes now, assuming you have created a MySQL database as shown in Chapter 4, and that the ToDo application is already switched over to using that. The first service is the EJB timer service, in ejb-deployer.xml. You should replace the reference to DefaultDS with a reference to the correct datasource. In Chapter 4, we chose the name MySqlDS. The change is simple:
JMS also requires persistence changes to be made. If you aren't using JMS and you chose to remove it from your configuration, you can stop here. Otherwise, go to the deploy/jms directory and look for hsqldb-jdbc2-service.xml and hsqldb-jdbc-state-service.xml. hsqldb-jdbc2-service.xml controls message persistence. You can remove it completely and replace it with a database-specific file from docs/examples/jms. For MySQL, copy mysql-jdbc2-service.xml into the jms directory. hsqldb-jdbc-state-service.xml isn't quite so simple. There are no database-specific templates for this. You'll need to update the datasource dependency manually:
This datasource reference needs to be the same as the datasource you saw earlier, in the jbossmq security domain in login-config.xml. You'll want to update that now too:
The final dependency on DefaultDS is uuid-key-generator.sar. If you aren't using the JBoss UUID key generator, remove this service from the deploy directory. If you are, you'll need to update the META-INF/jboss-service.xml file to reference the preferred datasource:
Unfortunately, this service is not provided in exploded form, so you'll have you unpack the archive to get to it. What just happened?You removed Hypersonic and updated, or removed, the services that depend on it. All of the persistent services will write their tables into the new database. If you've kept them around and restarted JBoss, you should find several new database tables in your external database:
You could have saved yourself some trouble by creating a replacement DefaultDS. Then it wouldn't have been necessary to change all the datasource references. However, it's important to be explicit about your configuration in a production machine. The extra effort is worth the peace of mind of knowing that all your persistent services are configured correctly. |
Wednesday, October 21, 2009
Removing Hypersonic
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment