static RoutableFactory createDocumentListMessageFactory() {
        return ProtobufCodecBuilder
                .of(DocumentListMessage.class, DocapiVisiting.DocumentListRequest.class)
                .encoder((apiMsg) -> {
                    var builder = DocapiVisiting.DocumentListRequest.newBuilder()
                            .setBucketId(toProtoBucketId(apiMsg.getBucketId()));
                    for (var doc : apiMsg.getDocuments()) {
                        builder.addEntries(DocapiVisiting.DocumentListRequest.Entry.newBuilder()
                                .setTimestamp(doc.getTimestamp())
                                .setIsTombstone(doc.isRemoveEntry())
                                .setDocument(toProtoDocument(doc.getDocument())));
                    }
                    return builder.build();
                })
                .decoderWithRepo(DocapiVisiting.DocumentListRequest.parser(), (protoMsg, repo) -> {
                    var msg = new DocumentListMessage();
                    msg.setBucketId(fromProtoBucketId(protoMsg.getBucketId()));
                    for (var entry : protoMsg.getEntriesList()) {
                        msg.getDocuments().add(new DocumentListEntry(
                                fromProtoDocument(entry.getDocument(), repo),
                                entry.getTimestamp(),
                                entry.getIsTombstone()));
                    }
                    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