org.jgroups.Message createJGMessage(Message<ID> gfmsg, JGAddress src, ID dst,
      short versionOrdinal) throws IOException {
    gfmsg.registerProcessor();
    org.jgroups.Message msg = new org.jgroups.Message();
    msg.setDest(null);
    msg.setSrc(src);
    setMessageFlags(gfmsg, msg);
    try {
      long start = services.getStatistics().startMsgSerialization();
      final KnownVersion version = Versioning
          .getKnownVersionOrDefault(Versioning.getVersion(versionOrdinal), KnownVersion.CURRENT);
      try (BufferDataOutputStream out_stream = new BufferDataOutputStream(version)) {
        VersioningIO.writeOrdinal(out_stream, KnownVersion.getCurrentVersion().ordinal(), true);
        if (encrypt != null) {
          out_stream.writeBoolean(true);
          writeEncryptedMessage(gfmsg, dst, versionOrdinal, out_stream);
        } else {
          out_stream.writeBoolean(false);
          serializeMessage(gfmsg, out_stream);
        }

        msg.setBuffer(out_stream.toByteArray());
      }
      services.getStatistics().endMsgSerialization(start);
    } catch (IOException ex) {
      logger.warn("Error serializing message", ex);
      throw ex;
    } catch (Exception ex) {
      logger.warn("Error serializing message", ex);
      throw new IOException("Error serializing message", ex.getCause());
    }
    return msg;
  }
This is the constructor to use to create a JGroups message holding a GemFire
DistributionMessage. It sets the appropriate flags in the Message and properly serializes the
DistributionMessage for the recipient's product version

@param gfmsg the DistributionMessage
@param src the sender address
@param versionOrdinal the version of the recipient
@return the new message
geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/messenger/JGroupsMessenger.java