static RoutableFactory createEmptyBucketsMessageFactory() {
        return ProtobufCodecBuilder
                .of(EmptyBucketsMessage.class, DocapiVisiting.EmptyBucketsRequest.class)
                .encoder((apiMsg) -> {
                    var builder = DocapiVisiting.EmptyBucketsRequest.newBuilder();
                    for (var id : apiMsg.getBucketIds()) {
                        builder.addBucketIds(toProtoBucketId(id));
                    }
                    return builder.build();
                })
                .decoder(DocapiVisiting.EmptyBucketsRequest.parser(), (protoMsg) -> {
                    var msg = new EmptyBucketsMessage();
                    for (var protoId : protoMsg.getBucketIdsList()) {
                        msg.getBucketIds().add(fromProtoBucketId(protoId));
                    }
                    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