}
while (pos < minLargeMessageSize);
totalSize += pos;
final SessionSendContinuationMessage chunk;
if (lastPacket)
{
if (!session.isCompressLargeMessages())
{
messageSize.set(totalSize);
}
byte[] buff2 = new byte[pos];
System.arraycopy(buff, 0, buff2, 0, pos);
buff = buff2;
chunk = new SessionSendContinuationMessage(msgI, buff, false, sendBlocking, messageSize.get());
}
else
{
chunk = new SessionSendContinuationMessage(msgI, buff, true, false);
}
if (sendBlocking && lastPacket)
{
// When sending it blocking, only the last chunk will be blocking.
channel.sendBlocking(chunk);
}
else
{
channel.send(chunk);
}
try
{
credits.acquireCredits(chunk.getPacketSize());
}
catch (InterruptedException e)
{
throw new HornetQInterruptedException(e);
}