I have a really strange bug in my application. I'm facing the problem that if I run my application in ServiceMix the resultset coming from SimpleJdbcCall contains always all the previous values from previous stored procedure calls.
However stores only the last value when running it locally.
My Camel route (with dummy names):
<from ref="cronQuartzEndpoint"/>
<to uri="bean:userDAO?method=listAll"/>
<split>
<simple>${body}</simple>
<to uri="bean:myStoredProcCaller?method=requestAndStoreUserName" />
<to uri="bean:userDAO?method=saveUser" />
</split>
Let's see the stored procedure caller logic. Let's say the stored procedure returns with the name of the user, and waits for the id as parameter.
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;
}
And my RowMapper is simple as this:
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);
}
};
The logs if I run my Camel route locally:
- userId: 1
- userNames: [Alice]
- userId: 2
- userNames: [Bob]
The logs if running it in ServiceMix:
- userId: 1
- userNames: [Alice]
- userId: 2
- userNames: [Alice, Bob]
The used versions of artifacts and all the configuration are the same on both side. Any ideas what is the logic behind this issue? Thanks, Gergely