Skip to content

Messaging: PayloadMethodArgumentResolver should call certain Decoders even if the message is empty #29898

Closed as not planned
@spheenik

Description

@spheenik

Affects: Spring-Messaging 6.0.3

I am currently implementing an application, that uses Protobuf over RSocket for communication.
In Protobuf, I can define a message sent to my application like this:

message ProductsRequest {
  optional string id = 1;
}

My MessageHandler is then defined like this:

@MessageMapping("products")
public Mono<ProductsResponse> handle(ProductsRequest request) {
    // implementaion
}

The request may contain an id, but it may be omitted.
In case the id is omitted, the message is encoded as an empty buffer (as per Protobuf spec).

However, in the class org.springframework.messaging.handler.annotation.reactive.PayloadMethodArgumentResolver, empty buffers are never passed to the decoder, and instead immediately filtered out. (via .filter(this::nonEmptyDataBuffer), which then results in an error because the MessageHandler's argument cannot be resolved.

I understand that this behavior is reasonable for a lot of decoders, however in the case of Protobuf is a nuisance.

I think the best way to implement this is to add a property to the decoder ("can decode empty") and then filter or not, based on this property. I would gladly spend some time on this and come up with a pull request, but I wanted to have some guidance first, to not sent a crappy pull request.

So, roughly, how should this be implemented?

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: messagingIssues in messaging modules (jms, messaging)status: supersededAn issue that has been superseded by anothertype: enhancementA general enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions