static RoutableFactory createPutDocumentMessageFactory() {
        return ProtobufCodecBuilder
                .of(PutDocumentMessage.class, DocapiFeed.PutDocumentRequest.class)
                .encoder((apiMsg) -> {
                    var builder = DocapiFeed.PutDocumentRequest.newBuilder()
                            .setForceAssignTimestamp(apiMsg.getTimestamp())
                            .setPersistedTimestamp(apiMsg.getPersistedTimestamp())
                            .setCreateIfMissing(apiMsg.getCreateIfNonExistent())
                            .setDocument(toProtoDocument(apiMsg.getDocumentPut().getDocument()));
                    if (apiMsg.getCondition().isPresent()) {
                        builder.setCondition(toProtoTasCondition(apiMsg.getCondition()));
                    }
                    return builder.build();
                })
                .decoderWithRepo(DocapiFeed.PutDocumentRequest.parser(), (protoMsg, repo) -> {
                    var doc = fromProtoDocument(protoMsg.getDocument(), repo);
                    var msg = new PutDocumentMessage(new DocumentPut(doc));
                    if (protoMsg.hasCondition()) {
                        msg.setCondition(fromProtoTasCondition(protoMsg.getCondition()));
                    }
                    msg.setTimestamp(protoMsg.getForceAssignTimestamp());
                    msg.setPersistedTimestamp(protoMsg.getPersistedTimestamp());
                    msg.setCreateIfNonExistent(protoMsg.getCreateIfMissing());
                    return msg;
                })
                .build();
    }
Implementation of MessageBus message request/response serialization built around Protocol Buffers.
documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/RoutableFactories80.java