From a2d92ef786ad6fd542afb82543784794321fd13d Mon Sep 17 00:00:00 2001 From: Timothy Bish Date: Wed, 26 Oct 2016 19:04:35 -0400 Subject: [PATCH] https://issues.apache.org/jira/browse/AMQ-6486 Ensure that message with no header is marked as non-persistent. --- .../amqp/message/InboundTransformer.java | 1 + .../amqp/JMSInteroperabilityTest.java | 2 +- .../amqp/interop/AmqpSendReceiveTest.java | 25 +++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/message/InboundTransformer.java b/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/message/InboundTransformer.java index 323a9c14bc..eaea705b60 100644 --- a/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/message/InboundTransformer.java +++ b/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/message/InboundTransformer.java @@ -108,6 +108,7 @@ public abstract class InboundTransformer { } } else { jms.setPriority((byte) Message.DEFAULT_PRIORITY); + jms.setPersistent(false); } final MessageAnnotations ma = amqp.getMessageAnnotations(); diff --git a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/JMSInteroperabilityTest.java b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/JMSInteroperabilityTest.java index e3d3b174ec..a91b685c63 100644 --- a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/JMSInteroperabilityTest.java +++ b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/JMSInteroperabilityTest.java @@ -198,7 +198,7 @@ public class JMSInteroperabilityTest extends JMSClientTestSupport { MessageProducer amqpProducer = amqpSession.createProducer(queue); MessageConsumer openwireConsumer = openwireSession.createConsumer(queue); - TextMessage outbound = openwireSession.createTextMessage(); + TextMessage outbound = amqpSession.createTextMessage(); outbound.setText(testMessageBody); outbound.setBooleanProperty("Boolean", bool); outbound.setByteProperty("Byte", bValue); diff --git a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpSendReceiveTest.java b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpSendReceiveTest.java index f0d6da8a3d..ef3f27dc37 100644 --- a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpSendReceiveTest.java +++ b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpSendReceiveTest.java @@ -477,6 +477,31 @@ public class AmqpSendReceiveTest extends AmqpClientTestSupport { connection.close(); } + @Test(timeout = 60000) + public void testMessageWithNoHeaderNotMarkedDurable() throws Exception { + AmqpClient client = createAmqpClient(); + AmqpConnection connection = trackConnection(client.connect()); + AmqpSession session = connection.createSession(); + + AmqpSender sender = session.createSender("queue://" + getTestName()); + AmqpReceiver receiver1 = session.createReceiver("queue://" + getTestName()); + + // Create default message that should be sent as non-durable + AmqpMessage message1 = new AmqpMessage(); + message1.setText("Test-Message -> non-durable"); + message1.setMessageId("ID:Message:1"); + sender.send(message1); + + receiver1.flow(1); + AmqpMessage message2 = receiver1.receive(50, TimeUnit.SECONDS); + assertNotNull("Should have read a message", message2); + assertFalse("Second message sent should not be durable", message2.isDurable()); + message2.accept(); + + sender.close(); + connection.close(); + } + @Test(timeout = 60000) public void testSendMessageToQueueNoPrefixReceiveWithPrefix() throws Exception { AmqpClient client = createAmqpClient();