public static void writeTaskIdTo(final TaskId taskId, final DataOutputStream out, final int version) throws IOException {
        out.writeInt(taskId.subtopology());
        out.writeInt(taskId.partition());
        if (version >= MIN_NAMED_TOPOLOGY_VERSION) {
            if (taskId.topologyName() != null) {
                out.writeInt(taskId.topologyName().length());
                out.writeChars(taskId.topologyName());
            } else {
                out.writeInt(0);
            }
        } else if (taskId.topologyName() != null) {
            throw new TaskAssignmentException("Named topologies are not compatible with protocol version " + version);
        }
    }
@throws IOException if cannot write to output stream
streams/src/main/java/org/apache/kafka/streams/processor/internals/assignment/ConsumerProtocolUtils.java