static RoutableFactory createStatBucketMessageFactory() {
        return ProtobufCodecBuilder
                .of(StatBucketMessage.class, DocapiInspect.StatBucketRequest.class)
                .encoder((apiMsg) ->
                        DocapiInspect.StatBucketRequest.newBuilder()
                                .setBucketId(toProtoBucketId(apiMsg.getBucketId()))
                                .setBucketSpace(toProtoBucketSpace(apiMsg.getBucketSpace()))
                                .setSelection(toProtoDocumentSelection(apiMsg.getDocumentSelection()))
                                .build())
                .decoder(DocapiInspect.StatBucketRequest.parser(), (protoMsg) ->
                        new StatBucketMessage(
                                fromProtoBucketId(protoMsg.getBucketId()),
                                fromProtoBucketSpace(protoMsg.getBucketSpace()),
                                fromProtoDocumentSelection(protoMsg.getSelection())))
                .build();
    }
Implementation of MessageBus message request/response serialization built around Protocol Buffers.
documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/RoutableFactories80.java