我想将ad对象类型传递给messageheaders,并在stompframehandler中使用它。有时我发送myobject1,有时发送myobject2。我希望处理程序使用头信息转换它。
Message<HeartBeat> msg = MessageBuilder.withPayload(payload)
.setHeader("payloadType", MyObject1.class)
.build();
@Component
@RequiredArgsConstructor
public class MyObject2Handler implements StompFrameHandler {
@SneakyThrows
@Override
public Type getPayloadType(StompHeaders stompHeaders) {
return stompHeaders.get("payloadType").get(0) ... ???
}
@Override
public void handleFrame(StompHeaders stompHeaders, Object o) {
log.info(" <<< in <<< [{}] with headers: [{}]", o, stompHeaders);
}
}
暂无答案!
目前还没有任何答案,快来回答吧!