This method will send a message to the attached client.

@param sibMessage

@return Returns the length of the message sent

@throws MessageEncodeFailedException
@throws IncorrectMessageTypeException
@throws MessageCopyFailedException
5386
int sendMessage(SIBusMessage sibMessage)
      throws MessageCopyFailedException,
             IncorrectMessageTypeException,
             MessageEncodeFailedException,
             UnsupportedEncodingException
   {
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "sendMessage", sibMessage);

      int msgLen = 0;

      // If we are at FAP9 or above we can do a 'chunked' send of the message in seperate
      // slices to make life easier on the Java memory manager
      final HandshakeProperties props = getConversation().getHandshakeProperties();
      if (props.getFapLevel() >= JFapChannelConstants.FAP_VERSION_9)
      {
         msgLen = sendChunkedMessage(sibMessage);
      }
      else
      {
         msgLen = sendEntireMessage(sibMessage, null);
      }

      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "sendMessage", msgLen);
      return msgLen;
   }
823615
public JsMessage createInboundWebMessage(String data) throws MessageDecodeFailedException {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "createInboundWebMessage", data);
    JsMessage message = WebJsMessageFactoryImpl.createInboundWebMessage(data);
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "createInboundWebMessage", message);
    return message;
  }
1067095
public void verifyMessageSize(int maxMessageSize) {
       Iterator<MessageAndOffset> shallowIter =  internalIterator(true);
       while(shallowIter.hasNext()) {
           MessageAndOffset messageAndOffset = shallowIter.next();
           int payloadSize = messageAndOffset.message.payloadSize();
           if(payloadSize > maxMessageSize) {
               throw new MessageSizeTooLargeException("payload size of " + payloadSize + " larger than " + maxMessageSize);
           }
       }
    }
823172
public int getMessageLength() {
    // Message type, number of transients
    int length = 1 + 4;
    if (this.transientRequests != null) {
      for (OnDemandRequest request : this.transientRequests) {
        length += request.getLength();
      }
    }

    return length;
  }
948474
public int getMessageLength() {
		// Message type
		int messageLength = 1;

		// Number of aliases
		messageLength += 4;

		if (this.aliases != null) {
			for (AttributeAlias alias : this.aliases) {
				// Alias number, name length
				messageLength += 8;
				try {
					messageLength += alias.attributeName.getBytes("UTF-16BE").length;
				} catch (UnsupportedEncodingException e) {
					log.error("Unable to encode strings into UTF-16.");
					e.printStackTrace();
				}
			}
		}

		return messageLength;
	}
1372447
@Override
	public void writeBytes(byte[] value, int offset, int length) throws JMSException
    {
        try
        {
            getOutput().write(value,offset,length);
        }
        catch (IOException e)
        {
            throw new FFMQException("Cannot write message body","IO_ERROR",e);
        }
    }
435723
@Override
    public void sendMessage(SyslogMessage message) throws IOException {
        sendCounter.incrementAndGet();
        long nanosBefore = System.nanoTime();

        try {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            Writer out = new OutputStreamWriter(baos, UTF_8);
            message.toSyslogMessage(messageFormat, out);
            out.flush();

            if (logger.isLoggable(Level.FINEST)) {
                logger.finest("Send syslog message " + new String(baos.toByteArray(), UTF_8));
            }
            byte[] bytes = baos.toByteArray();

            DatagramPacket packet = new DatagramPacket(bytes, bytes.length, syslogServerHostnameReference.get(), syslogServerPort);
            datagramSocket.send(packet);
        } catch (IOException e) {
            sendErrorCounter.incrementAndGet();
            throw e;
        } catch (RuntimeException e) {
            sendErrorCounter.incrementAndGet();
            throw e;
        } finally {
            sendDurationInNanosCounter.addAndGet(System.nanoTime() - nanosBefore);
        }
    }
1078263
private static JsJmsMessage decodeObjectBody(String body) throws MessageDecodeFailedException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "decodeObjectBody");
        JsJmsObjectMessage result = new JsJmsObjectMessageImpl(MfpConstants.CONSTRUCTOR_NO_OP);
        if (body != null)
            result.setSerializedObject(HexString.hexToBin(body, 0));
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "decodeObjectBody");
        return result;
    }
3348
public String getDecodedMessage()
    {
        if (message == null)
        {
            return null;
        }
        return new String(Base64.base64ToByteArray(message), Charset.forName("UTF-8"));
    }
525494
protected ByteBuf toByteBuf(final SipMessage msg) {
        try {
            final Buffer b = msg.toBuffer();
            final int capacity = b.capacity() + 2;
            final ByteBuf buffer = this.channel.alloc().buffer(capacity, capacity);

            for (int i = 0; i < b.getReadableBytes(); ++i) {
                buffer.writeByte(b.getByte(i));
            }
            buffer.writeByte(SipParser.CR);
            buffer.writeByte(SipParser.LF);
            return buffer;
        } catch (final IOException e) {
            // shouldn't be possible since the underlying buffer
            // from the msg is backed by a byte-array.
            // TODO: do something appropriate other than this
            throw new RuntimeException("Unable to convert SipMessage to a ByteBuf due to IOException", e);
        }
    }
459504
static int mergeDelimitedFrom(DataInput in, Object message, Schema schema, 
            boolean decodeNestedMessageAsGroup) throws IOException
    {
        final byte size = in.readByte();
        final int len = 0 == (size & 0x80) ? size : CodedInput.readRawVarint32(in, size);
        
        if(len < 0)
            throw ProtobufException.negativeSize();
        
        if(len != 0)
        {
            // not an empty message
            if(len > CodedInput.DEFAULT_BUFFER_SIZE && in instanceof InputStream)
            {
                // message too big
                final CodedInput input = new CodedInput(new LimitedInputStream((InputStream)in, len), 
                        decodeNestedMessageAsGroup);
                schema.mergeFrom(input, message);
                input.checkLastTagWas(0);
            }
            else
            {
                final byte[] buf = new byte[len];
                in.readFully(buf, 0, len);
                final ByteArrayInput input = new ByteArrayInput(buf, 0, len, 
                        decodeNestedMessageAsGroup);
                try
                {
                    schema.mergeFrom(input, message);
                }
                catch(ArrayIndexOutOfBoundsException e)
                {
                    throw ProtobufException.truncatedMessage(e);
                }
                input.checkLastTagWas(0);
            }
        }

        // check it since this message is embedded in the DataInput.
        if(!schema.isInitialized(message))
            throw new UninitializedMessageException(message, schema);
        
        return len;
    }
730646
public int getMessageLength() {
    // Message ID
    int length = 1;

    if (this.weights != null) {
      for (String origin : this.weights.keySet()) {
        // String prefix, weight
        length += 8;
        try {
          length += origin.getBytes("UTF-16BE").length;
        } catch (UnsupportedEncodingException uee) {
          log.error("Unable to encode to UTF-16BE.");
        }
      }
    }

    return length;
  }
383856
public int getMessageLength() {
		// Message Type, Identifier length
		int length = 1 + 4;

		// Identifier bytes
		if (this.identifier != null) {
			try {
				length += this.identifier.getBytes("UTF-16BE").length;
			} catch (UnsupportedEncodingException e) {
				log.error("UTF-16BE is unsupported in this environment.");
			}
		}

		// Ticket number
		length += 4;

		// Number of attributes
		length += 4;

		// Each attribute
		if (this.attributes != null) {
			for (Attribute attr : this.attributes) {
				length += attr.getClientLength();
			}
		}

		return length;
	}
1130210
private static JsJmsMessage decodeStreamBody(String body) throws MessageDecodeFailedException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "decodeStreamBody");
        JsJmsStreamMessage result = new JsJmsStreamMessageImpl(MfpConstants.CONSTRUCTOR_NO_OP);
        if (body != null) {
            try {
                StringTokenizer st = new StringTokenizer(body, "&");
                while (st.hasMoreTokens())
                    result.writeObject(decodeObject(st.nextToken()));
            } catch (UnsupportedEncodingException e) {
                FFDCFilter.processException(e, "com.ibm.ws.sib.mfp.impl.WebJsJmsMessageFactoryImpl.decodeStreamBody", "196");
                // This can't happen, as the Exception can only be thrown for an MQ message
                // which isn't what we have.
            }
        }
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "decodeStreamBody");
        return result;
    }
125733
@Nonnull
  public static String getExpandedMessage (@Nonnull final String sMsg)
  {
    final char cCheck = sMsg.length () == 8 ? sMsg.charAt (7) : '\u0000';
    final String sUpce = sMsg.substring (0, 0 + 7);
    final byte nNumberSystem = _extractNumberSystem (sUpce);
    if (nNumberSystem != 0 && nNumberSystem != 1)
      throw new IllegalArgumentException ("Invalid UPC-E message: " + sMsg);

    final StringBuilder aSB = new StringBuilder ();
    aSB.append (Byte.toString (nNumberSystem));
    final byte nMode = StringParser.parseByte (sUpce.substring (6, 6 + 1), (byte) -1);
    if (nMode >= 0 && nMode <= 2)
    {
      aSB.append (sUpce.substring (1, 1 + 2));
      aSB.append (Byte.toString (nMode));
      aSB.append ("0000");
      aSB.append (sUpce.substring (3, 3 + 3));
    }
    else
      if (nMode == 3)
      {
        aSB.append (sUpce.substring (1, 1 + 3));
        aSB.append ("00000");
        aSB.append (sUpce.substring (4, 4 + 2));
      }
      else
        if (nMode == 4)
        {
          aSB.append (sUpce.substring (1, 1 + 4));
          aSB.append ("00000");
          aSB.append (sUpce.substring (5, 5 + 1));
        }
        else
          if (nMode >= 5 && nMode <= 9)
          {
            aSB.append (sUpce.substring (1, 1 + 5));
            aSB.append ("0000");
            aSB.append (Byte.toString (nMode));
          }
          else
          {
            // Shouldn't happen
            throw new IllegalArgumentException ("Internal error");
          }
    final String sUpcaFinished = aSB.toString ();
    final char cExpectedCheck = calcChecksumChar (sUpcaFinished, sUpcaFinished.length ());
    if (cCheck != '\u0000' && cCheck != cExpectedCheck)
      throw new IllegalArgumentException ("Invalid checksum. Expected " + cExpectedCheck + " but was " + cCheck);

    return sUpcaFinished + cExpectedCheck;
  }
351675
public static FileMessage decode(String encodedMessage, File file) throws IOException {
		return decode(
			encodedMessage.isEmpty()
			? ByteArray.EMPTY_BYTE_ARRAY
			: new ByteArray(
				Base64Coder.decode(
					encodedMessage
				)
			),
			file
		);
	}
443767
private static int contentLength(Object msg) {
        if (msg instanceof MemcacheContent) {
            return ((MemcacheContent) msg).content().readableBytes();
        }
        if (msg instanceof ByteBuf) {
            return ((ByteBuf) msg).readableBytes();
        }
        if (msg instanceof FileRegion) {
            return (int) ((FileRegion) msg).count();
        }
        throw new IllegalStateException("unexpected message type: " + StringUtil.simpleClassName(msg));
    }