Ensure that message with no header is marked as non-persistent.
This commit is contained in:
Timothy Bish 2016-10-26 19:04:35 -04:00
parent cec3245a9f
commit a2d92ef786
3 changed files with 27 additions and 1 deletions

View File

@ -108,6 +108,7 @@ public abstract class InboundTransformer {
} }
} else { } else {
jms.setPriority((byte) Message.DEFAULT_PRIORITY); jms.setPriority((byte) Message.DEFAULT_PRIORITY);
jms.setPersistent(false);
} }
final MessageAnnotations ma = amqp.getMessageAnnotations(); final MessageAnnotations ma = amqp.getMessageAnnotations();

View File

@ -198,7 +198,7 @@ public class JMSInteroperabilityTest extends JMSClientTestSupport {
MessageProducer amqpProducer = amqpSession.createProducer(queue); MessageProducer amqpProducer = amqpSession.createProducer(queue);
MessageConsumer openwireConsumer = openwireSession.createConsumer(queue); MessageConsumer openwireConsumer = openwireSession.createConsumer(queue);
TextMessage outbound = openwireSession.createTextMessage(); TextMessage outbound = amqpSession.createTextMessage();
outbound.setText(testMessageBody); outbound.setText(testMessageBody);
outbound.setBooleanProperty("Boolean", bool); outbound.setBooleanProperty("Boolean", bool);
outbound.setByteProperty("Byte", bValue); outbound.setByteProperty("Byte", bValue);

View File

@ -477,6 +477,31 @@ public class AmqpSendReceiveTest extends AmqpClientTestSupport {
connection.close(); 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) @Test(timeout = 60000)
public void testSendMessageToQueueNoPrefixReceiveWithPrefix() throws Exception { public void testSendMessageToQueueNoPrefixReceiveWithPrefix() throws Exception {
AmqpClient client = createAmqpClient(); AmqpClient client = createAmqpClient();