}
MessageImpl protonMessage = new MessageImpl(header, deliveryAnnotations, messageAnnotations, props, applicationProperties, section, footer);
protonMessage.setMessageFormat(getMessageFormat(message.getLongProperty(new SimpleString(PROTON_MESSAGE_FORMAT))));
ByteBuffer buffer = ByteBuffer.wrap(new byte[size]);
final DroppingWritableBuffer overflow = new DroppingWritableBuffer();
int c = protonMessage.encode(new CompositeWritableBuffer(new WritableBuffer.ByteBufferWrapper(buffer), overflow));
if (overflow.position() > 0)
{
buffer = ByteBuffer.wrap(new byte[1024 * 4 + overflow.position()]);
c = protonMessage.encode(new WritableBuffer.ByteBufferWrapper(buffer));
}