int byteCount = 1;
Object messageCopy = message;
if( message instanceof ByteBuffer )
{
ByteBuffer rb = ( ByteBuffer ) message;
rb.mark();
byteCount = rb.remaining();
ByteBuffer wb = ByteBuffer.allocate( rb.remaining() );
wb.put( rb );
wb.flip();
rb.reset();