本文整理了Java中org.springframework.integration.support.AbstractIntegrationMessageBuilder.setHeaderIfAbsent()
方法的一些代码示例,展示了AbstractIntegrationMessageBuilder.setHeaderIfAbsent()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AbstractIntegrationMessageBuilder.setHeaderIfAbsent()
方法的具体详情如下:
包路径:org.springframework.integration.support.AbstractIntegrationMessageBuilder
类名称:AbstractIntegrationMessageBuilder
方法名:setHeaderIfAbsent
[英]Set the value for the given header name only if the header name is not already associated with a value.
[中]仅当标头名称尚未与值关联时,才为给定标头名称设置值。
代码示例来源:origin: spring-projects/spring-integration
@Override
public final Message<?> transform(Message<?> message) {
try {
Assert.notNull(message, "Message must not be null");
Object payload = message.getPayload();
Assert.notNull(payload, "Message payload must not be null");
Assert.isInstanceOf(File.class, payload, "Message payload must be of type [java.io.File]");
File file = (File) payload;
T result = this.transformFile(file);
Message<?> transformedMessage = getMessageBuilderFactory().withPayload(result)
.copyHeaders(message.getHeaders())
.setHeaderIfAbsent(FileHeaders.ORIGINAL_FILE, file)
.setHeaderIfAbsent(FileHeaders.FILENAME, file.getName())
.build();
if (this.deleteFiles) {
if (!file.delete() && this.logger.isWarnEnabled()) {
this.logger.warn("failed to delete File '" + file + "'");
}
}
return transformedMessage;
}
catch (Exception e) {
throw new MessagingException(message, "failed to transform File Message", e);
}
}
代码示例来源:origin: spring-projects/spring-integration-aws
@Override
protected void additionalOnSuccessHeaders(AbstractIntegrationMessageBuilder<?> messageBuilder,
AmazonWebServiceRequest request, Object result) {
if (result instanceof SendMessageResult) {
SendMessageResult sendMessageResult = (SendMessageResult) result;
messageBuilder.setHeaderIfAbsent(AwsHeaders.MESSAGE_ID, sendMessageResult.getMessageId());
messageBuilder.setHeaderIfAbsent(AwsHeaders.SEQUENCE_NUMBER, sendMessageResult.getSequenceNumber());
}
}
代码示例来源:origin: org.springframework.integration/spring-integration-aws
@Override
protected void additionalOnSuccessHeaders(AbstractIntegrationMessageBuilder<?> messageBuilder,
AmazonWebServiceRequest request, Object result) {
if (result instanceof SendMessageResult) {
SendMessageResult sendMessageResult = (SendMessageResult) result;
messageBuilder.setHeaderIfAbsent(AwsHeaders.MESSAGE_ID, sendMessageResult.getMessageId());
messageBuilder.setHeaderIfAbsent(AwsHeaders.SEQUENCE_NUMBER, sendMessageResult.getSequenceNumber());
}
}
代码示例来源:origin: spring-projects/spring-integration-aws
@Override
@SuppressWarnings("unchecked")
public void onSuccess(I request, O result) {
if (getAsyncHandler() != null) {
((AsyncHandler<I, O>) getAsyncHandler()).onSuccess(request, result);
}
if (getOutputChannel() != null) {
AbstractIntegrationMessageBuilder<?> messageBuilder =
getMessageBuilderFactory()
.fromMessage(message);
additionalOnSuccessHeaders(messageBuilder, request, result);
messageBuilder.setHeaderIfAbsent(AwsHeaders.SERVICE_RESULT, result);
AbstractAwsMessageHandler.this.messagingTemplate.send(getOutputChannel(), messageBuilder.build());
}
}
代码示例来源:origin: org.springframework.integration/spring-integration-aws
@Override
@SuppressWarnings("unchecked")
public void onSuccess(I request, O result) {
if (getAsyncHandler() != null) {
((AsyncHandler<I, O>) getAsyncHandler()).onSuccess(request, result);
}
if (getOutputChannel() != null) {
AbstractIntegrationMessageBuilder<?> messageBuilder =
getMessageBuilderFactory()
.fromMessage(message);
additionalOnSuccessHeaders(messageBuilder, request, result);
messageBuilder.setHeaderIfAbsent(AwsHeaders.SERVICE_RESULT, result);
AbstractAwsMessageHandler.this.messagingTemplate.send(getOutputChannel(), messageBuilder.build());
}
}
内容来源于网络,如有侵权,请联系作者删除!