@Override
    @SuppressWarnings("unchecked")
    protected <T> Schema<T> writeMessageIdTo(Output output, int fieldNumber,
            Message<T> message) throws IOException
    {
        int id;
        BaseHS<T> wrapper = (BaseHS<T>) getSchemaWrapper(message.getClass(), true);

        // wait till everything is completely set
        while (0 == (id = wrapper.id))
            LockSupport.parkNanos(1);

        output.writeUInt32(fieldNumber, id, false);

        // TODO allow the wrapper to return an override schema?
        return message.cachedSchema();
    }
Register a {@link Delegate} and assign an id.
<p>
Delegate ids start at 1.
protostuff-runtime-registry/src/main/java/io/protostuff/runtime/IncrementalIdStrategy.java