Connection pooling in Fuse ESB
paul.h Feb 28, 2013 1:40 AMFuse ESB Enterprise 7.1.0
PostgreSQL 9.2
I use tomcat jdbc pool with spring JdbcTemplate in my fuse esb applications for work with postgresql database. I publish connection pool as datasource service in osgi environment in blueprint and it is reused by several applications.
When I started testing the application, I found an interesting bug which concerns all data sources in XA mode.
I digg in sources of next libraries:
org.apache.aries.transaction/org.apache.aries.transaction.jdbc/1.0.1.fuse-71-047
org.apache.aries.transaction/org.apache.aries.transaction.manager/1.0.1.fuse-71-047
spring-jdbc
tomcat jdbc-pool
and found, that JdbcTemplate don't close connection if it's the transactional, and aries hasn't any option and code to release connection after global transaction commit or rollback.
For example I have next simple bean:
public class TestBean {
private JdbcTemplate jdbcTemplate;
public TestBean(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
}
@Transacted
public void test1() {
jdbcTemplate.update(....);
}
@Transacted
public void test2() {
jdbcTemplate.update(...);
}
@Transacted
public void test3() {
jdbcTemplate.update(...);
}
}
I have next situation:
1) I execute update method on jdbcTemplate in my test1() method. Spring container propagate global transaction context to it and after finishing update not release connection.
2) I execute next methods test2(), test3(), etc in same global transaction context
3) Transaction manager execute auto commit after all and also not realese used jdbc connections.
4) After next N executions getConnection() at tomcat jdbc pool datasource object I catch exception with message:
Timeout: Pool empty. Unable to fetch a connection in 30 seconds, none availablesize:50; busy:50; idle:0; lastwait:30000
Pool consider that all connections is busy, but actually all 50 connections simply is not released!
Workaround for tomcat jdbc-pool: removeAbandoned = true, but it is crutches.
Whether there are any instructions on use of the connection pooling in fuse esb except use of ancient dbcp or c3p0 libraries?
Thanks!