Source:
<code>public JdbcMessageHandler jdbcMessageHandler(DataSource dataSource) { final MultiValueMap<String, Expression> columnExpressionVariations = new LinkedMultiValueMap<>(); for (Map.Entry<String, String> entry : properties.getColumns().entrySet()) { String value = entry.getValue(); columnExpressionVariations.add(entry.getKey(), spelExpressionParser.parseExpression(value)); if (!value.startsWith("payload")) { columnExpressionVariations.add(entry.getKey(), spelExpressionParser.parseExpression("payload." + value)); } } JdbcMessageHandler jdbcMessageHandler = new JdbcMessageHandler(dataSource, generateSql(properties.getTableName(),columnExpressionVariations.keySet())); <START> jdbcMessageHandler.setSqlParameterSourceFactory( <END> new SqlParameterSourceFactory() { @Override public SqlParameterSource createParameterSource(Object o) { if (!(o instanceof Message)) { throw new IllegalArgumentException("Unable to handle type " + o.getClass().getName()); } Message<?> message = (Message<?>) o; MapSqlParameterSource parameterSource = new MapSqlParameterSource(); for (String key: columnExpressionVariations.keySet()) { List<Expression> spels = columnExpressionVariations.get(key); Object value = null; EvaluationException lastException = null; for (Expression spel : spels) { try { value = spel.getValue(evaluationContext, message); } catch (EvaluationException e) { lastException = e; } } parameterSource.addValue(key, value); } return parameterSource; } }); return jdbcMessageHandler; }</code><technical_language>Wondering if/how ExpressionEvaluatingSqlParameterSourceFactory here</technical_language>

Target:
public JdbcMessageHandler jdbcMessageHandler(DataSource dataSource) { final MultiValueMap<String, Expression> columnExpressionVariations = new LinkedMultiValueMap<>(); for (Map.Entry<String, String> entry : properties.getColumns().entrySet()) { String value = entry.getValue(); columnExpressionVariations.add(entry.getKey(), spelExpressionParser.parseExpression(value)); if (!value.startsWith("payload")) { columnExpressionVariations.add(entry.getKey(), spelExpressionParser.parseExpression("payload." + value)); } } JdbcMessageHandler jdbcMessageHandler = new JdbcMessageHandler(dataSource, generateSql(properties.getTableName(),columnExpressionVariations.keySet())); jdbcMessageHandler.setSqlParameterSourceFactory( new SqlParameterSourceFactory() { @Override public SqlParameterSource createParameterSource(Object o) { if (!(o instanceof Message)) { throw new IllegalArgumentException("Unable to handle type " + o.getClass().getName()); } Message<?> message = (Message<?>) o; MapSqlParameterSource parameterSource = new MapSqlParameterSource(); for (String key: columnExpressionVariations.keySet()) { List<Expression> spels = columnExpressionVariations.get(key); Object value = NOT_SET; EvaluationException lastException = null; for (Expression spel : spels) { try { value = spel.getValue(evaluationContext, message); break; } catch (EvaluationException e) { lastException = e; } } if (value == NOT_SET) { if (lastException != null) { logger.info("Could not find value for column '" + key + "': " + lastException.getMessage()); } parameterSource.addValue(key, null); } else { if (value instanceof JsonPropertyAccessor.ToStringFriendlyJsonNode) { DirectFieldAccessor dfa = new DirectFieldAccessor(value); JsonNode node = (JsonNode) dfa.getPropertyValue("node"); Object valueToUse; if (node == null || node.isNull()) { valueToUse = null; } else if (node.isNumber()) { valueToUse = node.numberValue(); } else if (node.isBoolean()) { valueToUse = node.booleanValue(); } else { valueToUse = node.textValue(); } parameterSource.addValue(key, valueToUse); } else { parameterSource.addValue(key, value); } } } return parameterSource; } }); return jdbcMessageHandler; }