Use case: Developers want to create Protobuf service implementation, more efficient. However, also need to expose as rest/json, to support clients that consume json -- perhaps we are in technology-transition time?

This does not work for netty/webflux, but works for tomcat, so likely some platform config issue?

Please make it easy to expose PROTO implementation as rest, without code duplication.

Spring Add JSON support to Protobuf codecs

https://stackoverflow.com/questions/60289736/spring-webflux-netty-no-tomcat-how-to-expose-proto-as-json-endopints-without/63022169#63022169

Comment From: bucknerns

+1

Comment From: sdeleuze

Protobuf support is provided in Spring WebFlux via ProtobufDecoder and ProtobufEncoder. Could you please check what prevents you to use that support?

Comment From: bucknerns

Json serialization/deserialization doesn't work for protobufs when using webflux.

Comment From: sdeleuze

Ok I understand now, so this is about providing similar capablities than ProtobufJsonFormatHttpMessageConverter bu on codecs/WebFlux side.

Comment From: bucknerns

Any word on this?

Comment From: sazonenka

Any updates on that?

Comment From: kitkars

@rstoyanchev It would be great if you could prioritize this. We all see the benefit of webflux. but no support for protobuf :(

Comment From: rstoyanchev

This should be feasible, just mirroring what we've already done on the HttpMessageConverter side. I've scheduled it to have a look for the upcoming 6.1 milestone.

Comment From: bucknerns

Updates?

Comment From: bclozel

@bucknerns we didn't get to this issue in time for 6.1. We're trying to prioritize specific themes and most requested features in our roadmap. We'll try to tackle this one in 6.2 but at two votes this hardly makes it a top priority right now.

Comment From: bclozel

@HubertWo please use the GitHub voting feature by adding your vote on the original issue comment. Writing "+1" comments just adds noise and is not counted against the total vote count.

Comment From: bucknerns

@kitkars @sazonenka Can you plus the issue by hitting the thumbs up on the first comment.

Comment From: bclozel

Thanks to all for upvoting this issue. We now have a dedicated codec for Protobuf+JSON.

This comes with a noteworthy limitation: this codec does not support the deserialization of JSON arrays into Flux<Message>. We would need a non-blocking parser able to tokenize JSON arrray elements into DataBuffer. This is supported for Jackson, as Jackson itself provides a non-blocking parser in the first place. This is not the case for Protobuf Java Util and probably out of scope for this library.

In practice this means that Mono and Flux are supported as return types for WebFlux controllers signatures:

@GetMapping(path="/users", produces = "application/json")
Flux<User> listUsers();

@GetMapping(path="/users/{id}", produces = "application/json")
Mono<User> showUser(@Pathvariable String id);

But only Mono types are supported when reading request bodies:

@PostMapping(path="/users/create", consumes = "application/json")
Mono<Void> createUser(@RequestBody Mono<User> user)

// this case is not supported
@PostMapping(path="/users/createMany", consumes = "application/json")
Mono<Void> createUsers(@RequestBody Flux<User>> users)

// this should be used instead
@PostMapping(path="/users/createMany", consumes = "application/json")
Mono<Void> createUsers(@RequestBody Mono<List<User>> users)

We'll document further this support in #33063