copyStandardHeadersFromFrameToMessage(command, msg);
return msg;
}
protected StompFrame convertMessage(Message message) throws IOException, JMSException {
StompFrame command = new StompFrame();
command.setAction(Stomp.Responses.MESSAGE);
Map headers = new HashMap(25);
command.setHeaders(headers);
copyStandardHeadersFromMessageToFrame(message, command);
if (message instanceof TextMessage) {
TextMessage msg = (TextMessage) message;
command.setContent(msg.getText().getBytes("UTF-8"));
}
else if (message instanceof BytesMessage) {
BytesMessage msg = (BytesMessage) message;
byte[] data = new byte[(int) msg.getBodyLength()];
msg.readBytes(data);
headers.put(Stomp.Headers.CONTENT_LENGTH, "" + data.length);
command.setContent(data);
}
return command;
}