1 14 15 package org.apache.activemq.broker.region.cursors; 16 17 import javax.jms.Connection ; 18 import javax.jms.ConnectionFactory ; 19 import javax.jms.Destination ; 20 import javax.jms.JMSException ; 21 import javax.jms.MessageConsumer ; 22 import javax.jms.Session ; 23 import javax.jms.Topic ; 24 import org.apache.activemq.broker.BrokerService; 25 26 29 public class CursorDurableTest extends CursorSupport{ 30 31 protected Destination getDestination(Session session) throws JMSException { 32 String topicName=getClass().getName(); 33 return session.createTopic(topicName); 34 } 35 36 protected Connection getConsumerConnection(ConnectionFactory fac) throws JMSException { 37 Connection connection=fac.createConnection(); 38 connection.setClientID("testConsumer"); 39 connection.start(); 40 return connection; 41 } 42 43 protected MessageConsumer getConsumer(Connection connection) throws Exception { 44 Session consumerSession=connection.createSession(false,Session.AUTO_ACKNOWLEDGE); 45 Topic topic=(Topic )getDestination(consumerSession); 46 MessageConsumer consumer=consumerSession.createDurableSubscriber(topic,"testConsumer"); 47 return consumer; 48 } 49 50 protected void configureBroker(BrokerService answer) throws Exception { 51 answer.setDeleteAllMessagesOnStartup(true); 52 answer.addConnector(bindAddress); 53 answer.setDeleteAllMessagesOnStartup(true); 54 } 55 } 56 | Popular Tags |