@Override
public MuleEvent process(MuleEvent muleEvent) throws MuleException
{
DbConnection connection = null;
DbConfig dbConfig = dbConfigResolver.resolve(muleEvent);
try
{
connection = dbConfig.getConnectionFactory().createConnection(transactionalAction);
Object result = executeQuery(connection, muleEvent);
if (mustCloseConnection())
{
try
{
dbConfig.getConnectionFactory().releaseConnection(connection);
}
finally
{
connection = null;
}
}
if (target == null || "".equals(target) || "#[payload]".equals(target))
{
muleEvent.getMessage().setPayload(result);
}
else
{
muleContext.getExpressionManager().enrich(target, muleEvent, result);
}
return processNext(muleEvent);
}
catch (SQLException e)
{
throw new MessagingException(muleEvent, e);
}
finally
{
if (connection != null && mustCloseConnection())
{
dbConfig.getConnectionFactory().releaseConnection(connection);
}
}
}