org.springframework.core.AttributeAccessor Java Examples

The following examples show how to use org.springframework.core.AttributeAccessor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultPollableMessageSource.java    From spring-cloud-stream with Apache License 2.0 6 votes vote down vote up
/**
 * 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);
			}
		}
	}
}
 
Example #2
Source File: DefaultPollableMessageSource.java    From spring-cloud-stream with Apache License 2.0 4 votes vote down vote up
public void setAttributesProvider(
		BiConsumer<AttributeAccessor, Message<?>> attributesProvider) {
	this.attributesProvider = attributesProvider;
}