Get bytes messages to work right with pub sub.

git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@394242 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Hiram R. Chirino 2006-04-15 02:05:04 +00:00
parent 5706bed79d
commit e73fa1201a
2 changed files with 5 additions and 8 deletions

View File

@ -24,7 +24,6 @@ import java.util.Properties;
import javax.jms.JMSException;
import org.apache.activeio.packet.ByteSequence;
import org.apache.activemq.command.ActiveMQBytesMessage;
import org.apache.activemq.command.ActiveMQDestination;
import org.apache.activemq.command.ActiveMQMessage;
@ -59,8 +58,7 @@ class Send implements StompCommand {
byte nil = in.readByte();
if (nil != 0)
throw new ProtocolException("content-length bytes were read and " + "there was no trailing null byte");
ByteSequence content = new ByteSequence(bytes, 0, bytes.length);
bm.setContent(content);
bm.writeBytes(bytes);
msg = bm;
}
else {
@ -125,9 +123,7 @@ class Send implements StompCommand {
msg.setTransactionId(tx_id);
}
msg.setReadOnlyBody(true);
msg.setReadOnlyProperties(true);
msg.onSend();
return new CommandEnvelope(msg, headers);
}

View File

@ -76,9 +76,10 @@ public class Subscription {
builder.addHeaders(m);
if( m.getDataStructureType() == ActiveMQTextMessage.DATA_STRUCTURE_TYPE ) {
builder.setBody(((ActiveMQTextMessage)m).getText().getBytes("UTF-8"));
ActiveMQTextMessage msg = (ActiveMQTextMessage)m.copy();
builder.setBody(msg.getText().getBytes("UTF-8"));
} else if( m.getDataStructureType() == ActiveMQBytesMessage.DATA_STRUCTURE_TYPE ) {
ActiveMQBytesMessage msg = (ActiveMQBytesMessage)m;
ActiveMQBytesMessage msg = (ActiveMQBytesMessage)m.copy();
byte[] data = new byte[(int)msg.getBodyLength()];
msg.readBytes(data);
builder.addHeader(Stomp.Headers.CONTENT_LENGTH, data.length);