You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by or...@apache.org on 2018/06/05 23:01:35 UTC
[2/2] qpid-broker-j git commit: QPID-8202: [Broker-J][AMQP 0-9] Make
sure that message content is loaded from disk only once before sending it to
the client
QPID-8202: [Broker-J][AMQP 0-9] Make sure that message content is loaded from disk only once before sending it to the client
Project: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/commit/c101fbcd
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/c101fbcd
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/c101fbcd
Branch: refs/heads/master
Commit: c101fbcd26f68b249bc8ae47b7afec7e1875f1f9
Parents: 025b48f
Author: Alex Rudyy <or...@apache.org>
Authored: Tue Jun 5 23:38:32 2018 +0100
Committer: Alex Rudyy <or...@apache.org>
Committed: Tue Jun 5 23:59:53 2018 +0100
----------------------------------------------------------------------
.../v0_8/ProtocolOutputConverterImpl.java | 31 +++++++++++---------
1 file changed, 17 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/c101fbcd/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/ProtocolOutputConverterImpl.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/ProtocolOutputConverterImpl.java b/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/ProtocolOutputConverterImpl.java
index d9465b3..bcc515b 100644
--- a/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/ProtocolOutputConverterImpl.java
+++ b/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/ProtocolOutputConverterImpl.java
@@ -183,20 +183,23 @@ public class ProtocolOutputConverterImpl implements ProtocolOutputConverter
int writtenSize = capacity;
- AMQBody firstContentBody = new MessageContentSourceBody(content, 0, capacity);
+ try (QpidByteBuffer contentByteBuffer = content.getContent())
+ {
+ AMQBody firstContentBody = new MessageContentSourceBody(contentByteBuffer, 0, capacity);
- CompositeAMQBodyBlock
- compositeBlock =
- new CompositeAMQBodyBlock(channelId, deliverBody, contentHeaderBody, firstContentBody);
- writeFrame(compositeBlock);
+ CompositeAMQBodyBlock
+ compositeBlock =
+ new CompositeAMQBodyBlock(channelId, deliverBody, contentHeaderBody, firstContentBody);
+ writeFrame(compositeBlock);
- while (writtenSize < bodySize)
- {
- capacity = bodySize - writtenSize > maxBodySize ? maxBodySize : bodySize - writtenSize;
- AMQBody body = new MessageContentSourceBody(content, writtenSize, capacity);
- writtenSize += capacity;
+ while (writtenSize < bodySize)
+ {
+ capacity = bodySize - writtenSize > maxBodySize ? maxBodySize : bodySize - writtenSize;
+ AMQBody body = new MessageContentSourceBody(contentByteBuffer, writtenSize, capacity);
+ writtenSize += capacity;
- writeFrame(new AMQFrame(channelId, body));
+ writeFrame(new AMQFrame(channelId, body));
+ }
}
}
}
@@ -210,10 +213,10 @@ public class ProtocolOutputConverterImpl implements ProtocolOutputConverter
{
public static final byte TYPE = 3;
private final int _length;
- private final MessageContentSource _content;
+ private final QpidByteBuffer _content;
private final int _offset;
- public MessageContentSourceBody(MessageContentSource content, int offset, int length)
+ public MessageContentSourceBody(QpidByteBuffer content, int offset, int length)
{
_content = content;
_offset = offset;
@@ -236,7 +239,7 @@ public class ProtocolOutputConverterImpl implements ProtocolOutputConverter
public long writePayload(final ByteBufferSender sender)
{
long size;
- try (final QpidByteBuffer content = _content.getContent(_offset, _length))
+ try (final QpidByteBuffer content = _content.view(_offset, _length))
{
size = content.remaining();
sender.send(content);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org