static RoutableFactory createRemoveDocumentMessageFactory() {
        return ProtobufCodecBuilder
                .of(RemoveDocumentMessage.class, DocapiFeed.RemoveDocumentRequest.class)
                .encoder((apiMsg) -> {
                    var builder = DocapiFeed.RemoveDocumentRequest.newBuilder()
                            .setDocumentId(toProtoDocId(apiMsg.getDocumentId()))
                            .setPersistedTimestamp(apiMsg.getPersistedTimestamp());
                    if (apiMsg.getCondition().isPresent()) {
                        builder.setCondition(toProtoTasCondition(apiMsg.getCondition()));
                    }
                    return builder.build();
                })
                .decoder(DocapiFeed.RemoveDocumentRequest.parser(), (protoMsg) -> {
                    var msg = new RemoveDocumentMessage(fromProtoDocId(protoMsg.getDocumentId()));
                    if (protoMsg.hasCondition()) {
                        msg.setCondition(fromProtoTasCondition(protoMsg.getCondition()));
                    }
                    msg.setPersistedTimestamp(protoMsg.getPersistedTimestamp());
                    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