mirror of https://github.com/apache/activemq.git
Patch applied for https://issues.apache.org/activemq/browse/AMQ-2833
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@965542 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
607f1ef669
commit
c6af867113
|
@ -37,7 +37,28 @@ public class LegacyFrameTranslator implements FrameTranslator {
|
||||||
public ActiveMQMessage convertFrame(ProtocolConverter converter, StompFrame command) throws JMSException, ProtocolException {
|
public ActiveMQMessage convertFrame(ProtocolConverter converter, StompFrame command) throws JMSException, ProtocolException {
|
||||||
final Map headers = command.getHeaders();
|
final Map headers = command.getHeaders();
|
||||||
final ActiveMQMessage msg;
|
final ActiveMQMessage msg;
|
||||||
if (headers.containsKey(Stomp.Headers.CONTENT_LENGTH)) {
|
/*
|
||||||
|
* To reduce the complexity of this method perhaps a Chain of Responsibility
|
||||||
|
* would be a better implementation
|
||||||
|
*/
|
||||||
|
if (headers.containsKey(Stomp.Headers.AMQ_MESSAGE_TYPE)) {
|
||||||
|
String intendedType = (String)headers.get(Stomp.Headers.AMQ_MESSAGE_TYPE);
|
||||||
|
if(intendedType.equalsIgnoreCase("text")){
|
||||||
|
ActiveMQTextMessage text = new ActiveMQTextMessage();
|
||||||
|
try {
|
||||||
|
text.setText(new String(command.getContent(), "UTF-8"));
|
||||||
|
} catch (Throwable e) {
|
||||||
|
throw new ProtocolException("Text could not bet set: " + e, false, e);
|
||||||
|
}
|
||||||
|
msg = text;
|
||||||
|
} else if(intendedType.equalsIgnoreCase("bytes")) {
|
||||||
|
ActiveMQBytesMessage byteMessage = new ActiveMQBytesMessage();
|
||||||
|
byteMessage.writeBytes(command.getContent());
|
||||||
|
msg = byteMessage;
|
||||||
|
} else {
|
||||||
|
throw new ProtocolException("Unsupported message type '"+intendedType+"'",false);
|
||||||
|
}
|
||||||
|
}else if (headers.containsKey(Stomp.Headers.CONTENT_LENGTH)) {
|
||||||
headers.remove(Stomp.Headers.CONTENT_LENGTH);
|
headers.remove(Stomp.Headers.CONTENT_LENGTH);
|
||||||
ActiveMQBytesMessage bm = new ActiveMQBytesMessage();
|
ActiveMQBytesMessage bm = new ActiveMQBytesMessage();
|
||||||
bm.writeBytes(command.getContent());
|
bm.writeBytes(command.getContent());
|
||||||
|
|
|
@ -50,6 +50,11 @@ public interface Stomp {
|
||||||
String CONTENT_LENGTH = "content-length";
|
String CONTENT_LENGTH = "content-length";
|
||||||
String TRANSFORMATION = "transformation";
|
String TRANSFORMATION = "transformation";
|
||||||
String TRANSFORMATION_ERROR = "transformation-error";
|
String TRANSFORMATION_ERROR = "transformation-error";
|
||||||
|
/**
|
||||||
|
* This header is used to instruct ActiveMQ to construct the message
|
||||||
|
* based with a specific type.
|
||||||
|
*/
|
||||||
|
String AMQ_MESSAGE_TYPE = "amq-msg-type";
|
||||||
|
|
||||||
public interface Response {
|
public interface Response {
|
||||||
String RECEIPT_ID = "receipt-id";
|
String RECEIPT_ID = "receipt-id";
|
||||||
|
|
Loading…
Reference in New Issue