Source:
public void configureMessageChannel(MessageChannel messageChannel, String channelName) { BindingProperties bindingProperties = channelBindingServiceProperties.getBindings().get(channelName); if (bindingProperties != null && Boolean.TRUE.equals(bindingProperties.isTrackHistory())) { final Set<String> trackHistoryProperties = StringUtils.commaDelimitedListToSet(bindingProperties.getTrackHistoryProperties()); Map<String, Object> channelBindingServicePropertiesMap = channelBindingServiceProperties.asMapProperties(); final Map<String, Object> historyMap = new HashMap<>(); if (bindingProperties.getTrackHistoryProperties().equalsIgnoreCase("all")) { historyMap.putAll(channelBindingServicePropertiesMap); } else { for (String property : trackHistoryProperties) { if (channelBindingServicePropertiesMap.keySet().contains(property)) { historyMap.put(property, channelBindingServicePropertiesMap.get(property)); } } } if (messageChannel instanceof ChannelInterceptorAware) { ((ChannelInterceptorAware) messageChannel).addInterceptor(new ChannelInterceptorAdapter() { @Override public Message<?> preSend(Message<?> message, MessageChannel channel) { @SuppressWarnings("unchecked") Collection<Map<String, Object>> history = (Collection<Map<String, Object>>) message.getHeaders().get(HISTORY_TRACKING_HEADER); if (history == null) { history = new ArrayList<>(1); } else { history = new ArrayList<>(history); } Map<String, Object> map = new LinkedHashMap<String, Object>(); map.put("thread", Thread.currentThread().getName()); map.putAll(historyMap); history.add(map); Message<?> out = messageBuilderFactory .fromMessage(message) .setHeader(HISTORY_TRACKING_HEADER, history) .build(); map.put("timestamp", out.getHeaders().getTimestamp()); return out; } }); } } }

Target:
public void configureMessageChannel(MessageChannel messageChannel, String channelName) { BindingProperties bindingProperties = channelBindingServiceProperties.getBindings().get(channelName); if (bindingProperties != null && Boolean.TRUE.equals(bindingProperties.isTrackHistory())) { final Set<String> trackHistoryProperties = StringUtils.commaDelimitedListToSet(bindingProperties.getTrackedProperties()); Map<String, Object> channelBindingServicePropertiesMap = channelBindingServiceProperties.asMapProperties(); final Map<String, Object> historyMap = new HashMap<>(); if (bindingProperties.getTrackedProperties().equalsIgnoreCase("all")) { historyMap.putAll(channelBindingServicePropertiesMap); } else { for (String property : trackHistoryProperties) { if (channelBindingServicePropertiesMap.keySet().contains(property)) { historyMap.put(property, channelBindingServicePropertiesMap.get(property)); } } } if (messageChannel instanceof ChannelInterceptorAware) { ((ChannelInterceptorAware) messageChannel).addInterceptor(new ChannelInterceptorAdapter() { @Override public Message<?> preSend(Message<?> message, MessageChannel channel) { @SuppressWarnings("unchecked") Collection<Map<String, Object>> history = (Collection<Map<String, Object>>) message.getHeaders().get(HISTORY_TRACKING_HEADER); if (history == null) { history = new ArrayList<>(1); } else { history = new ArrayList<>(history); } Map<String, Object> map = new LinkedHashMap<String, Object>(); map.put("thread", Thread.currentThread().getName()); map.putAll(historyMap); history.add(map); Message<?> out = messageBuilderFactory .fromMessage(message) .setHeader(HISTORY_TRACKING_HEADER, history) .build(); map.put("timestamp", out.getHeaders().getTimestamp()); return out; } }); } } }