Monthly Archives: September 2012

Issues with Spring’s ResourceBundleMessageSource

In Spring, you can use ResourceBundleMessageSource to resolve text messages from properties file, based on the selected locales. Follow this link for an introductory example on how to do so.

This post details on two bottlenecks with this message source’s implementation that we encountered through load tests.

Read the rest of this entry

Scheduling a batch file every 10 seconds

Recently while investigating high cpu issues in an web application, I wanted to take thread dumps (through jstack) every 10 seconds. First thought was to schedule the batch file through a task scheduler, but I realized that with the task scheduler you cannot set a repetition interval lower then a minute.

An alternative approach would be to use a ping command in the batch file.

Read the rest of this entry

Detecting connection leaks with tomcat connection pool

Tomcat’s JDBC connection pool can help you detect connection leaks in your web application. It provides the below three attributes in order to do this


(boolean) Flag to remove abandoned connections if they exceed the removeAbandonedTimout. If set to true a connection is considered abandoned and eligible for removal if it has been in use longer than the removeAbandonedTimeout Setting this to true can recover db connections from applications that fail to close a connection. See also logAbandoned The default value is false.
removeAbandonedTimeout (int) Timeout in seconds before an abandoned(in use) connection can be removed. The default value is 60 seconds. The value should be set to the longest running query your applications might have.
logAbandoned (boolean) Flag to log stack traces for application code which abandoned a Connection. Logging of abandoned Connections adds overhead for every Connection borrow because a stack trace has to be generated. The default value is false.

Spring commits on NOT_SUPPORTED propagation level

If you are working with spring and executing a DML query inside a transaction which has a propagation level of NOT_SUPPORTED, you might get surprised that the DML query gets committed despite the fact that the propagation level is NOT_SUPPORTED.

Read the rest of this entry