Skip to content
Permalink
Browse files
ARTEMIS-3696 avoid null prop values on STOMP msgs
  • Loading branch information
jbertram authored and clebertsuconic committed Feb 28, 2022
1 parent 2d16ec3 commit c4ebccd94dcad1f133f2205d343f6eb08b2e92e0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
@@ -47,10 +47,14 @@ public static void copyStandardHeadersFromFrameToMessage(StompFrame frame, Messa
if (persistent != null) {
msg.setDurable(Boolean.parseBoolean(persistent));
}

msg.putObjectProperty(MessageUtil.CORRELATIONID_HEADER_NAME, headers.remove(Stomp.Headers.Send.CORRELATION_ID));
msg.putObjectProperty(MessageUtil.TYPE_HEADER_NAME, headers.remove(Stomp.Headers.Send.TYPE));

String correlationID = headers.remove(Stomp.Headers.Send.CORRELATION_ID);
if (correlationID != null) {
msg.putObjectProperty(MessageUtil.CORRELATIONID_HEADER_NAME, correlationID);
}
String type = headers.remove(Stomp.Headers.Send.TYPE);
if (type != null) {
msg.putObjectProperty(MessageUtil.TYPE_HEADER_NAME, type);
}
String groupID = headers.remove(MessageUtil.JMSXGROUPID);
if (groupID != null) {
msg.putStringProperty(Message.HDR_GROUP_ID, SimpleString.toSimpleString(groupID));
@@ -57,7 +57,9 @@
import org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl;
import org.apache.activemq.artemis.core.server.impl.AddressInfo;
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
import org.apache.activemq.artemis.jms.client.ActiveMQMessage;
import org.apache.activemq.artemis.logs.AssertionLoggerHandler;
import org.apache.activemq.artemis.reader.MessageUtil;
import org.apache.activemq.artemis.tests.integration.mqtt.FuseMQTTClientProvider;
import org.apache.activemq.artemis.tests.integration.mqtt.MQTTClientProvider;
import org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame;
@@ -244,6 +246,21 @@ public void testSendMessage() throws Exception {
Assert.assertTrue(Math.abs(tnow - tmsg) < 1000);
}

@Test
public void testNullCorrelationIDandTypeProperties() throws Exception {

MessageConsumer consumer = session.createConsumer(queue);

conn.connect(defUser, defPass);

send(conn, getQueuePrefix() + getQueueName(), null, "Hello World");

TextMessage message = (TextMessage) consumer.receive(1000);
Assert.assertNotNull(message);
Assert.assertFalse(((ActiveMQMessage)message).getCoreMessage().getPropertyNames().contains(MessageUtil.CORRELATIONID_HEADER_NAME));
Assert.assertFalse(((ActiveMQMessage)message).getCoreMessage().getPropertyNames().contains(MessageUtil.TYPE_HEADER_NAME));
}

@Test
public void sendSTOMPReceiveMQTT() throws Exception {
// Set up MQTT Subscription

0 comments on commit c4ebccd

Please sign in to comment.