String destination = (String)headers.remove(Stomp.Headers.Send.DESTINATION);
String txID = (String)headers.remove(Stomp.Headers.TRANSACTION);
long timestamp = System.currentTimeMillis();
SimpleString address = SimpleString.toSimpleString(destination);
ServerMessageImpl message = new ServerMessageImpl(server.getStorageManager().generateUniqueID(), 512);
message.setTimestamp(timestamp);
message.setAddress(address);
validateDestination(address);
StompUtils.copyStandardHeadersFromFrameToMessage(frame, message);
if (headers.containsKey(Stomp.Headers.CONTENT_LENGTH))
{
message.setType(Message.BYTES_TYPE);
message.getBodyBuffer().writeBytes(frame.getContent());
}
else
{
message.setType(Message.TEXT_TYPE);
String text = new String(frame.getContent(), "UTF-8");
message.getBodyBuffer().writeNullableSimpleString(SimpleString.toSimpleString(text));
}
StompSession stompSession = null;
if (txID == null)
{
stompSession = getSession(connection);
}
else
{
stompSession = getTransactedSession(connection, txID);
}
if (stompSession.isNoLocal())
{
message.putStringProperty(CONNECTION_ID_PROP, connection.getID().toString());
}
stompSession.sendInternal(message, true);
return null;
}