Stored procedures ServiceMix中的Spring JdbcTemplate/SimpleJDBCall有状态

Stored procedures ServiceMix中的Spring JdbcTemplate/SimpleJDBCall有状态,stored-procedures,apache-camel,spring-jdbc,apache-servicemix,Stored Procedures,Apache Camel,Spring Jdbc,Apache Servicemix,我的应用程序中有一个非常奇怪的错误。我面临的问题是,如果在ServiceMix中运行我的应用程序,来自SimpleJDBCall的结果集始终包含来自以前存储过程调用的所有以前的值 但是,在本地运行时,仅存储最后一个值 我的骆驼路线(使用虚拟名称): ${body} 让我们看看存储过程调用逻辑。假设存储过程返回用户名,并等待id作为参数 public User requestAndStoreUserName(User user) { LOG.info("userId: " + user

我的应用程序中有一个非常奇怪的错误。我面临的问题是,如果在ServiceMix中运行我的应用程序,来自SimpleJDBCall的结果集始终包含来自以前存储过程调用的所有以前的值

但是,在本地运行时,仅存储最后一个值

我的骆驼路线(使用虚拟名称):


${body}
让我们看看存储过程调用逻辑。假设存储过程返回用户名,并等待id作为参数

public User requestAndStoreUserName(User user) {
    LOG.info("userId: " + user.getId());

    //I know it's not necessary but I added it to ensure that new RowMapper is generated
    mySimpleJdbcCall.returningResultSet(USER_NAME_FIELD, new UserNameRowMapper());
    mySimpleJdbcCall.compile();

    Map<String, Object> results = mySimpleJdbcCall.execute(user.getId());

    List<String> userNames = (List<String>)results.get(USER_NAME_FIELD);
    LOG.info("userNames: " + userNames );
    if ( !userNames .isEmpty() ) {
        user.setName(userNames.get(0));
    }
    return user;
}
public User requestAndStoreUserName(用户){
LOG.info(“userId:+user.getId());
//我知道这不是必需的,但我添加了它以确保生成新的行映射器
mySimpleJDBCall.returningResultSet(用户名字段,新用户名行映射器());
mySimpleJdbcCall.compile();
Map results=mySimpleJdbcCall.execute(user.getId());
List userNames=(List)results.get(USER\u NAME\u字段);
LOG.info(“用户名:”+用户名);
如果(!userNames.isEmpty()){
user.setName(userNames.get(0));
}
返回用户;
}
我的RowMapper很简单,如下所示:

private static class UserNameRowMapper implements RowMapper<String> {
    @Override
    public String mapRow(ResultSet rs, int rowNum) throws SQLException {
        return rs.getString(USER_NAME_RESPONSE_FIELD_INDEX);
    }
};
私有静态类UserNameRowMapper实现了RowMapper{
@凌驾
公共字符串mapRow(ResultSet rs,int rowNum)引发SQLException{
返回rs.getString(用户名\响应\字段\索引);
}
};
如果我在本地运行我的驼峰路线,则会显示以下日志:

  • 用户ID:1
  • 用户名:[爱丽丝]
  • 用户ID:2
  • 用户名:[鲍勃]
在ServiceMix中运行时的日志:

  • 用户ID:1
  • 用户名:[爱丽丝]
  • 用户ID:2
  • 用户名:[爱丽丝,鲍勃]

工件的使用版本和所有配置在两侧都是相同的。你知道这个问题背后的逻辑吗?谢谢,Gergely

我使用的数据源背后隐藏着一个问题:首先,我使用了commons.dbcp.BasicDataSource,它使用池。当我将它更改为spring.jdbc.SimpleDriverDataSource时,它就开始工作了。这一个总是请求到DB的新连接,而前一个使用它的连接池。 但是,BasicDataSource仍然可以与maven一起使用,但在SMX中没有-->我还没有检查BasicDataSource的源,但是我的本地maven依赖项与在SMX中找到的依赖项之间的唯一区别是:在我的maven中,我没有导入commons池,而这个包安装在SMX中。我假设有一个内部机制,以防目录中没有公用池

private static class UserNameRowMapper implements RowMapper<String> {
    @Override
    public String mapRow(ResultSet rs, int rowNum) throws SQLException {
        return rs.getString(USER_NAME_RESPONSE_FIELD_INDEX);
    }
};