mirror of https://github.com/apache/activemq.git
Stomp should now not pass through headers with null values in the AMQ message (correlation-id, reply-to, etc)
git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@431714 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f012622ff4
commit
7d4cddd452
|
@ -546,15 +546,21 @@ public class ProtocolConverter {
|
|||
|
||||
headers.put(Stomp.Headers.Message.DESTINATION, convertDestination(message.getDestination()));
|
||||
headers.put(Stomp.Headers.Message.MESSAGE_ID, message.getJMSMessageID());
|
||||
headers.put(Stomp.Headers.Message.CORRELATION_ID, message.getJMSCorrelationID());
|
||||
if (message.getJMSCorrelationID() != null) {
|
||||
headers.put(Stomp.Headers.Message.CORRELATION_ID, message.getJMSCorrelationID());
|
||||
}
|
||||
headers.put(Stomp.Headers.Message.EXPIRATION_TIME, ""+message.getJMSExpiration());
|
||||
if (message.getJMSRedelivered()) {
|
||||
headers.put(Stomp.Headers.Message.REDELIVERED, "true");
|
||||
}
|
||||
headers.put(Stomp.Headers.Message.PRORITY, ""+message.getJMSPriority());
|
||||
headers.put(Stomp.Headers.Message.REPLY_TO, convertDestination(message.getJMSReplyTo()));
|
||||
if (message.getJMSReplyTo() != null) {
|
||||
headers.put(Stomp.Headers.Message.REPLY_TO, convertDestination(message.getJMSReplyTo()));
|
||||
}
|
||||
headers.put(Stomp.Headers.Message.TIMESTAMP, ""+message.getJMSTimestamp());
|
||||
headers.put(Stomp.Headers.Message.TYPE, message.getJMSType());
|
||||
if (message.getJMSType() != null) {
|
||||
headers.put(Stomp.Headers.Message.TYPE, message.getJMSType());
|
||||
}
|
||||
|
||||
// now lets add all the message headers
|
||||
Map properties = message.getProperties();
|
||||
|
|
|
@ -25,12 +25,7 @@ import org.apache.activemq.command.ActiveMQQueue;
|
|||
import org.apache.activemq.command.ActiveMQTextMessage;
|
||||
import org.apache.activemq.transport.stomp.Stomp;
|
||||
|
||||
import javax.jms.Connection;
|
||||
import javax.jms.JMSException;
|
||||
import javax.jms.MessageConsumer;
|
||||
import javax.jms.MessageProducer;
|
||||
import javax.jms.Session;
|
||||
import javax.jms.TextMessage;
|
||||
import javax.jms.*;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -39,6 +34,8 @@ import java.io.OutputStream;
|
|||
import java.net.Socket;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.net.URI;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
public class StompTest extends CombinationTestSupport {
|
||||
|
||||
|
@ -122,6 +119,14 @@ public class StompTest extends CombinationTestSupport {
|
|||
producer.send(message);
|
||||
}
|
||||
|
||||
public void sendBytesMessage(byte[] msg) throws Exception{
|
||||
MessageProducer producer = session.createProducer(queue);
|
||||
BytesMessage message = session.createBytesMessage();
|
||||
message.writeBytes(msg);
|
||||
producer.send(message);
|
||||
|
||||
}
|
||||
|
||||
public void testConnect() throws Exception {
|
||||
|
||||
String connect_frame = "CONNECT\n" + "login: brianm\n" + "passcode: wombats\n" + "request-id: 1\n" + "\n" + Stomp.NULL;
|
||||
|
@ -166,7 +171,6 @@ public class StompTest extends CombinationTestSupport {
|
|||
assertTrue( Math.abs(tnow - tmsg) < 1000 );
|
||||
}
|
||||
|
||||
|
||||
public void testJMSXGroupIdCanBeSet() throws Exception {
|
||||
|
||||
MessageConsumer consumer = session.createConsumer(queue);
|
||||
|
@ -300,6 +304,45 @@ public class StompTest extends CombinationTestSupport {
|
|||
sendFrame(frame);
|
||||
}
|
||||
|
||||
public void testSubscribeWithAutoAckAndBytesMessage() throws Exception {
|
||||
|
||||
String frame =
|
||||
"CONNECT\n" +
|
||||
"login: brianm\n" +
|
||||
"passcode: wombats\n\n"+
|
||||
Stomp.NULL;
|
||||
sendFrame(frame);
|
||||
|
||||
frame = receiveFrame(100000);
|
||||
assertTrue(frame.startsWith("CONNECTED"));
|
||||
|
||||
frame =
|
||||
"SUBSCRIBE\n" +
|
||||
"destination:/queue/" + getQueueName() + "\n" +
|
||||
"ack:auto\n\n" +
|
||||
Stomp.NULL;
|
||||
sendFrame(frame);
|
||||
|
||||
sendBytesMessage(new byte[] {1,2,3,4,5});
|
||||
|
||||
frame = receiveFrame(10000);
|
||||
assertTrue(frame.startsWith("MESSAGE"));
|
||||
|
||||
Pattern cl = Pattern.compile("Content-length:\\s*(\\d+)", Pattern.CASE_INSENSITIVE);
|
||||
Matcher cl_matcher = cl.matcher(frame);
|
||||
assertTrue(cl_matcher.find());
|
||||
assertEquals("5", cl_matcher.group(1));
|
||||
|
||||
Pattern null_type_pattern = Pattern.compile("type:\\s*null", Pattern.CASE_INSENSITIVE);
|
||||
assertFalse(null_type_pattern.matcher(frame).find());
|
||||
|
||||
frame =
|
||||
"DISCONNECT\n" +
|
||||
"\n\n"+
|
||||
Stomp.NULL;
|
||||
sendFrame(frame);
|
||||
}
|
||||
|
||||
public void testSubscribeWithMessageSentWithProperties() throws Exception {
|
||||
|
||||
String frame =
|
||||
|
|
Loading…
Reference in New Issue