public StompCommand updateStompCommandAsClientMessage() {

    Assert.state(
        SimpMessageType.MESSAGE.equals(getMessageType()),
        "Unexpected message type " + getMessage());

    if (getCommand() == null) {
      setHeader(COMMAND_HEADER, StompCommand.SEND);
    } else if (!getCommand().equals(StompCommand.SEND)) {
      throw new IllegalStateException("Unexpected STOMP command " + getCommand());
    }

    return getCommand();
  }
  public void updateStompCommandAsServerMessage() {

    Assert.state(
        SimpMessageType.MESSAGE.equals(getMessageType()),
        "Unexpected message type " + getMessage());

    StompCommand command = getCommand();
    if ((command == null) || StompCommand.SEND.equals(command)) {
      setHeader(COMMAND_HEADER, StompCommand.MESSAGE);
    } else if (!StompCommand.MESSAGE.equals(command)) {
      throw new IllegalStateException("Unexpected STOMP command " + command);
    }

    trySetStompHeaderForSubscriptionId();

    if (getMessageId() == null) {
      String messageId = getSessionId() + "-" + messageIdCounter.getAndIncrement();
      setNativeHeader(STOMP_MESSAGE_ID_HEADER, messageId);
    }
  }