1 18 package org.apache.activemq.perf; 19 20 import javax.jms.Connection ; 21 import javax.jms.Destination ; 22 import javax.jms.JMSException ; 23 import javax.jms.MessageConsumer ; 24 import javax.jms.Session ; 25 import org.apache.activemq.broker.BrokerService; 26 import org.apache.activemq.store.kahadaptor.KahaPersistenceAdapter; 27 30 public class QueueConnectionMemoryTest extends SimpleQueueTest{ 31 32 protected void setUp() throws Exception { 33 } 34 35 protected void tearDown() throws Exception { 36 37 } 38 39 protected Destination createDestination(Session s,String destinationName) throws JMSException { 40 return s.createTemporaryQueue(); 41 } 42 43 44 45 public void testPerformance() throws JMSException { 46 } 48 49 protected void configureBroker(BrokerService answer) throws Exception { 50 KahaPersistenceAdapter adaptor = new KahaPersistenceAdapter(); 51 answer.setPersistenceAdapter(adaptor); 52 answer.addConnector(bindAddress); 53 answer.setDeleteAllMessagesOnStartup(true); 54 } 55 56 public void testMemory() throws Exception { 57 if(broker==null){ 58 broker=createBroker(); 59 } 60 factory=createConnectionFactory(); 61 Connection con=factory.createConnection(); 62 Session session=con.createSession(false,Session.AUTO_ACKNOWLEDGE); 63 destination=createDestination(session,DESTINATION_NAME); 64 con.close(); 65 for (int i =0; i < 3;i++) { 66 Connection connection=factory.createConnection(); 67 connection.start(); 68 Session s=connection.createSession(false,Session.AUTO_ACKNOWLEDGE); 69 Destination dest = s.createTemporaryQueue(); 70 MessageConsumer consumer=s.createConsumer(dest); 71 System.out.println("Created connnection: " + i); 72 Thread.sleep(1000); 73 } 74 75 Thread.sleep(Integer.MAX_VALUE); 76 } 77 } 78 | Popular Tags |