use of org.springframework.core.AttributeAccessor in project spring-integration-aws by spring-projects.
the class KinesisMessageDrivenChannelAdapter method setAttributesIfNecessary.
/**
* If there's an error channel, we create a new attributes holder here.
* Then set the attributes for use by the {@link ErrorMessageStrategy}.
* @param record the Kinesis record to use.
* @param message the Spring Messaging message to use.
*/
private void setAttributesIfNecessary(Object record, Message<?> message) {
if (getErrorChannel() != null) {
AttributeAccessor attributes = ErrorMessageUtils.getAttributeAccessor(message, null);
attributesHolder.set(attributes);
attributes.setAttribute(AwsHeaders.RAW_RECORD, record);
}
}
use of org.springframework.core.AttributeAccessor in project spring-cloud-stream by spring-cloud.
the class DefaultPollableMessageSource method setAttributesIfNecessary.
/**
* 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);
}
}
}
}
use of org.springframework.core.AttributeAccessor in project spring-integration by spring-projects.
the class AmqpInboundGateway method setAttributesIfNecessary.
/**
* 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 amqpMessage the AMQP message to use.
* @param message the Spring Messaging message to use.
* @since 4.3.10
*/
private void setAttributesIfNecessary(Message amqpMessage, org.springframework.messaging.Message<?> message) {
boolean needHolder = getErrorChannel() != 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);
attributes.setAttribute(AmqpMessageHeaderErrorMessageStrategy.AMQP_RAW_MESSAGE, amqpMessage);
}
}
}
use of org.springframework.core.AttributeAccessor in project spring-integration by spring-projects.
the class AmqpInboundChannelAdapter method setAttributesIfNecessary.
/**
* 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 amqpMessage the AMQP message to use.
* @param message the Spring Messaging message to use.
* @since 4.3.10
*/
private void setAttributesIfNecessary(Message amqpMessage, org.springframework.messaging.Message<?> message) {
boolean needHolder = getErrorChannel() != 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);
attributes.setAttribute(AmqpMessageHeaderErrorMessageStrategy.AMQP_RAW_MESSAGE, amqpMessage);
}
}
}
Aggregations