我正在使用带有 websockets 的 spring-messaging。目前我有一个@MessageMapping控制器来从 websocket 客户端获取数据。
@MessageMapping("/path1")
@SendTo("/queue/path1-data")
public BrokerPacket myController(String message) throws Exception {
return new BrokerPacket(message, "1234", "5677");
}
我的 BrokerPacket 看起来像:
public class BrokerPacket {
private String data;
private String value1;
private String value2;
public BrokerPacket(String data, String value1, String value2) {
this.data = data;
this.value1 = value1;
this.value2 = value2;
}
}
这给了我一个MessageConversionException
org.springframework.messaging.converter.MessageConversionException: Unable to convert payload with type='com.company.dto.BrokerPacket', contentType='null', converter=[CompositeMessageConverter[converters=[org.springframework.messaging.converter.StringMessageConverter@2f9f7783, org.springframework.messaging.converter.ByteArrayMessageConverter@312048e, org.springframework.messaging.converter.MappingJackson2MessageConverter@7764e617]]]
at org.springframework.messaging.core.AbstractMessageSendingTemplate.doConvert(AbstractMessageSendingTemplate.java:186) ~[spring-messaging-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.messaging.core.AbstractMessageSendingTemplate.convertAndSend(AbstractMessageSendingTemplate.java:149) ~[spring-messaging-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.messaging.core.AbstractMessageSendingTemplate.convertAndSend(AbstractMessageSendingTemplate.java:128) ~[spring-messaging-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.messaging.simp.annotation.support.SendToMethodReturnValueHandler.handleReturnValue(SendToMethodReturnValueHandler.java:188) ~[spring-messaging-5.0.6.RELEASE.jar:5.0.6.RELEASE]
繁花不似锦
相关分类