1 18 19 package org.apache.activemq.usecases; 20 import javax.jms.Connection ; 21 import javax.jms.Destination ; 22 import javax.jms.IllegalStateException ; 23 import javax.jms.JMSException ; 24 import javax.jms.Message ; 25 import javax.jms.MessageConsumer ; 26 import javax.jms.MessageListener ; 27 import javax.jms.Session ; 28 29 import org.apache.activemq.test.TestSupport; 30 31 34 public class ChangeSessionDeliveryModeTest extends TestSupport implements MessageListener { 35 36 42 public void testDoChangeSessionDeliveryMode() throws Exception { 43 Destination destination = createDestination("foo.bar"); 44 Connection connection = createConnection(); 45 connection.start(); 46 Session consumerSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); 47 MessageConsumer consumer1 = consumerSession.createConsumer(destination); 48 consumer1.setMessageListener(this); 49 JMSException jmsEx = null; 50 MessageConsumer consumer2 = consumerSession.createConsumer(destination); 51 52 try { 53 consumer2.receive(10); 54 fail("Did not receive expected exception."); 55 } 56 catch (JMSException e) { 57 assertTrue(e instanceof IllegalStateException ); 58 } 59 } 60 61 public void onMessage(Message msg) { 62 } 63 } 64 | Popular Tags |