Encodes the current Message contents into the given {@link WritableBuffer} instance.
<p>
This method attempts to encode all message data into the {@link WritableBuffer} and
if the buffer has insufficient space it will throw an exception to indicate the buffer
overflow condition. If successful the method returns the number of bytes written to
the provided buffer to fully encode the message.
@param buffer
The {@link WritableBuffer} instance to encode the message contents into.
@return the number of bytes written to fully encode the message.
Encodes the current Message contents into the given {@link WritableBuffer} instance. <p> This method attempts to encode all message data into the {@link WritableBuffer} and if the buffer has insufficient space it will throw an exception to indicate the buffer overflow condition. If successful the method returns the number of bytes written to the provided buffer to fully encode the message.
@param buffer The {@link WritableBuffer} instance to encode the message contents into.
@return the number of bytes written to fully encode the message.