1 18 package org.apache.activemq; 19 20 import javax.jms.Message ; 21 import javax.jms.Session ; 22 import javax.jms.TextMessage ; 23 24 27 public class JMSDurableTopicRedeliverTest extends JmsTopicRedeliverTest { 28 29 private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory 30 .getLog(JMSDurableTopicRedeliverTest.class); 31 32 protected void setUp() throws Exception { 33 durable = true; 34 super.setUp(); 35 } 36 37 42 public void testRedeliverNewSession() throws Exception { 43 String text = "TEST: "+System.currentTimeMillis(); 44 Message sendMessage = session.createTextMessage(text); 45 46 if (verbose) { 47 log.info("About to send a message: " + sendMessage + " with text: " + text); 48 } 49 producer.send(producerDestination, sendMessage); 50 51 Message unackMessage = consumer.receive(1000); 53 assertNotNull(unackMessage); 54 String unackId = unackMessage.getJMSMessageID(); 55 assertEquals(((TextMessage ) unackMessage).getText(), text); 56 assertFalse(unackMessage.getJMSRedelivered()); 57 assertEquals(unackMessage.getIntProperty("JMSXDeliveryCount"),1); 58 consumeSession.close(); 59 consumer.close(); 60 61 consumeSession = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE); 63 consumer = createConsumer(); 64 Message ackMessage = consumer.receive(1000); 65 assertNotNull(ackMessage); 66 ackMessage.acknowledge(); 67 String ackId = ackMessage.getJMSMessageID(); 68 assertEquals(((TextMessage ) ackMessage).getText(), text); 69 assertTrue(ackMessage.getJMSRedelivered()); 70 assertEquals(ackMessage.getIntProperty("JMSXDeliveryCount"),2); 71 assertEquals(unackId, ackId); 72 consumeSession.close(); 73 consumer.close(); 74 75 consumeSession = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE); 76 consumer = createConsumer(); 77 assertNull(consumer.receive(1000)); 78 } 79 } 80 | Popular Tags |