我想将版本:1.1添加到STOMP消息头中,如下所示:
destination:/cora/1234/panelapp/code/response content-type:application/json;charset=UTF-8 subscription:sub-0 message-id:bdyqehdj-5 content-length:492 **Version: 1.2**
@Override
public Message<?> preSend(Message<?> message, MessageChannel channel) {
StompHeaderAccessor sha = StompHeaderAccessor.wrap(message);
StompCommand command = sha.getCommand();
sha.setHeader(sha.STOMP_MESSAGE_HEADER, "1.2");
sha.setVersion("1.2");
sha.addNativeHeader(sha.STOMP_MESSAGE_HEADER, "1.2");
return message;
}
但是在postSend方法中,我无法在标题中找到版本信息。如何将版本信息导入PostSend方法,该方法是从ChannelInterceptorAdapter中的preSend方法设置的。
更新:
@Override public Message<?> preSend(Message<?> message, MessageChannel channel) {
return MessageBuilder.fromMessage(message).setHeader("Version","1.2").build();
}
答案 0 :(得分:1)
我们可以将标题设置为键/值对:
MutableMessageBuilder.fromMessage(message)
.setHeader("key","value")
.build();