Skip to content

@MessageMapping should support generically typed Message argument with converted payload [SPR-13288] #17878

Closed
@spring-projects-issues

Description

@spring-projects-issues

pascal gehl opened SPR-13288 and commented

I have a @Controller method wired with a @MessagingGateway annotated service.

@MessageMapping(value = "/messages/save")
public void save(Message<ToBeSaved> msg) {
     service.save(msg);
 }

Unfortunately this does not work; I get

SimpAnnotationMethodMessageHandler -- Unhandled exception
MethodArgumentTypeMismatchException: Could not resolve method parameter at index 0 in method: public void MyEndpoint.save(Message<ToBeSaved>) The expected Message<?> payload type [ToBeSaved] does not match the actual payload type [[B]
	at org.springframework.messaging.handler.annotation.support.MessageMethodArgumentResolver.resolveArgument(MessageMethodArgumentResolver.java:59)

After investigation generic Message<CustomClass> is not understood as being a Message instance with ToBeSaved payload class but only Message<?> with Byte[] payload.

It would be nice if MessageMethodArgumentResolver was able to use MessageConverter the same way PayloadArgumentResolver can.


Affects: 4.1.7

Issue Links:

Referenced from: commits 416966d

1 votes, 7 watchers

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions