docs: DataSlice encodeSinglePartMessage(Object conn) throws MessageEncodeFailedException {
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "encodeSinglePartMessage");
  
      // We must only use this method if the message does not have a payload part
      if (payloadPart != null) {
        MessageEncodeFailedException mefe = new MessageEncodeFailedException("Invalid call to encodeSinglePartMessage");
        FFDCFilter.processException(mefe, "com.ibm.ws.sib.mfp.impl.JsMsgObject.encodeSinglePartMessage", "jmo530", this,
            new Object[] { MfpConstants.DM_MESSAGE, headerPart.jmfPart, theMessage });
        throw mefe;
      }
  
      // The 'conn' parameter (if supplied) is passed as an Object (for no good reason except the
      // daft build system), but it has to be a CommsConnection instance.
      if (conn != null && !(conn instanceof CommsConnection)) {
        throw new MessageEncodeFailedException("Incorrect connection object: " + conn.getClass());
      }
  
      byte[] buffer = null;
  
      // Encoding is handled by JMF.  This will be a very cheap operation if JMF already has the
      // message in assembled form (for example if it was previously decoded from a byte buffer and
      // has had no major changes).
      try {
  
        // We need to lock the message around the call to updateDataFields() and the
        // actual encode of the part(s), so that noone can update any JMF message data
        // during that time (because they can not get the hdr2, api, or payload part).
        // Otherwise it is possible to get an inconsistent view of the message with some updates
        // included but those to the cached values 'missing'.
        // It is still strictly possible for the top-level schema header fields to be
        // updated, but this will not happen to any fields visible to an app.
        synchronized(theMessage) {
  
          // Ensure any cached message data is written back
          theMessage.updateDataFields(MfpConstants.UDF_ENCODE);
  
          // We need to check if the receiver has all the necessary schema definitions to be able
          // to decode this message and pre-send any that are missing.
          ensureReceiverHasSchemata((CommsConnection)conn);
  
          // Synchronize this section on the JMF Message, as otherwise the length could
          // change between allocating the array & encoding the header part into it.
          synchronized (getPartLockArtefact(headerPart)) {
  
            // Allocate a buffer for the Ids and the message part
            buffer = new byte[ IDS_LENGTH
                             + ArrayUtil.INT_SIZE
                             + ((JMFMessage)headerPart.jmfPart).getEncodedLength()
                             ];
  
            // Write the Ids to the buffer
            int offset = encodeIds(buffer, 0);
  
            // Write the header part to the buffer & add it to the buffer list
            encodePartToBuffer(headerPart, true, buffer, offset);
          }
        }
  
      }
      catch (MessageEncodeFailedException e1) {
        // This will have been thrown by encodePartToBuffer() which will
        // already have dumped the appropriate message part.
        FFDCFilter.processException(e1, "com.ibm.ws.sib.mfp.impl.JsMsgObject.encodeSinglePartMessage", "jmo500", this,
          new Object[] { MfpConstants.DM_MESSAGE, null, theMessage });
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "encodeSinglePartMessage failed: " + e1);
        throw e1;
      }
      catch (Exception e) {
        // This is most likely to be thrown by the getEncodedLength() call on the header
        // so we pass the header part to the diagnostic module.
        FFDCFilter.processException(e, "com.ibm.ws.sib.mfp.impl.JsMsgObject.encodeSinglePartMessage", "jmo520", this,
          new Object[] { MfpConstants.DM_MESSAGE, headerPart.jmfPart, theMessage });
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "encodeSinglePartMessage failed: " + e);
        throw new MessageEncodeFailedException(e);
      }
  
        // If debug trace, dump the buffer before returning
      if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "Encoded JMF Message", debugMsg());
      if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
        SibTr.debug(this, tc, "buffers: ", SibTr.formatBytes(buffer, 0, buffer.length));
      }
  
      // Wrap the buffer in a DataSlice to return
      DataSlice slice = new DataSlice(buffer);
  
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "encodeSinglePartMessage", slice);
      return slice;
    }