INT-4244: Optimize JpaOutboundGateway for Message

JIRA: https://jira.spring.io/browse/INT-4244

The `JpaOutboundGateway` returns a whole `Message` for reply copying request headers.
Building the reply a `AbstractMessageProducingHandler` uses `MessageBuilder` to create a new `Message` with all request headers because of `shouldCopyRequestHeaders() == true`

* To avoid some overhead with new `Message` and `MessageBuilder` for nothing, just return a JPA result as is and let super class to build the Message

* Optimize all reply producers to return `MessageBuilder` to the super `handleMessage()` process
* Return the whole `gatherResult` `Message<?>` from the `ScatterGatherHandler` to have ability to transfer reply headers as well
* Mark `DelayHandler`  as `shouldCopyRequestHeaders() return false` since it doesn't modify Message and returns it as is after delay
This commit is contained in:
Artem Bilan
2017-03-16 10:10:01 -04:00
committed by Gary Russell
parent 752fe0356f
commit df9593a528
13 changed files with 120 additions and 109 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2016 the original author or authors.
* Copyright 2014-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,6 +33,7 @@ import org.springframework.util.IdGenerator;
/**
* @author David Liu
* @author Artem Bilan
*
* @since 4.1
*/
public class RedisQueueOutboundGateway extends AbstractReplyProducingMessageHandler {
@@ -117,7 +118,8 @@ public class RedisQueueOutboundGateway extends AbstractReplyProducingMessageHand
return null;
}
if (this.extractPayload) {
return this.getMessageBuilderFactory().withPayload(replyMessage).build();
return getMessageBuilderFactory()
.withPayload(replyMessage);
}
else {
return replyMessage;