/** * If there's a retry template, it will set the attributes holder via the listener. If * there's no retry template, but there's an error channel, we create a new attributes * holder here. If an attributes holder exists (by either method), we set the * attributes for use by the {@link ErrorMessageStrategy}. * @param message the Spring Messaging message to use. */ private void setAttributesIfNecessary(Message<?> message) { boolean needHolder = this.errorChannel != null && this.retryTemplate == null; boolean needAttributes = needHolder || this.retryTemplate != null; if (needHolder) { attributesHolder.set(ErrorMessageUtils.getAttributeAccessor(null, null)); } if (needAttributes) { AttributeAccessor attributes = attributesHolder.get(); if (attributes != null) { attributes.setAttribute(ErrorMessageUtils.INPUT_MESSAGE_CONTEXT_KEY, message); if (this.attributesProvider != null) { this.attributesProvider.accept(attributes, message); } } } }
public void setAttributesProvider(BiConsumer<AttributeAccessor, Message<?>> attributesProvider) { this.attributesProvider = attributesProvider; }