KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > broker > region > cursors > CursorDurableTest


1 /**
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE
4  * file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file
5  * to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
6  * License. You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
11  * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
12  * specific language governing permissions and limitations under the License.
13  */

14
15 package org.apache.activemq.broker.region.cursors;
16
17 import javax.jms.Connection JavaDoc;
18 import javax.jms.ConnectionFactory JavaDoc;
19 import javax.jms.Destination JavaDoc;
20 import javax.jms.JMSException JavaDoc;
21 import javax.jms.MessageConsumer JavaDoc;
22 import javax.jms.Session JavaDoc;
23 import javax.jms.Topic JavaDoc;
24 import org.apache.activemq.broker.BrokerService;
25
26 /**
27  * @version $Revision: 1.3 $
28  */

29 public class CursorDurableTest extends CursorSupport{
30
31     protected Destination JavaDoc getDestination(Session JavaDoc session) throws JMSException JavaDoc{
32         String JavaDoc topicName=getClass().getName();
33         return session.createTopic(topicName);
34     }
35
36     protected Connection JavaDoc getConsumerConnection(ConnectionFactory JavaDoc fac) throws JMSException JavaDoc{
37         Connection JavaDoc connection=fac.createConnection();
38         connection.setClientID("testConsumer");
39         connection.start();
40         return connection;
41     }
42
43     protected MessageConsumer JavaDoc getConsumer(Connection JavaDoc connection) throws Exception JavaDoc{
44         Session JavaDoc consumerSession=connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
45         Topic JavaDoc topic=(Topic JavaDoc)getDestination(consumerSession);
46         MessageConsumer JavaDoc consumer=consumerSession.createDurableSubscriber(topic,"testConsumer");
47         return consumer;
48     }
49     
50     protected void configureBroker(BrokerService answer) throws Exception JavaDoc{
51         answer.setDeleteAllMessagesOnStartup(true);
52         answer.addConnector(bindAddress);
53         answer.setDeleteAllMessagesOnStartup(true);
54     }
55 }
56
Popular Tags