KickJava   Java API By Example, From Geeks To Geeks.

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


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 org.apache.activemq.broker.BrokerService;
24 import org.apache.activemq.broker.region.policy.PolicyEntry;
25 import org.apache.activemq.broker.region.policy.PolicyMap;
26 import org.apache.activemq.broker.region.policy.StorePendingDurableSubscriberMessageStoragePolicy;
27 import org.apache.activemq.broker.region.policy.StorePendingQueueMessageStoragePolicy;
28
29 /**
30  * @version $Revision: 1.3 $
31  */

32 public class CursorQueueStoreTest extends CursorSupport{
33
34     protected Destination JavaDoc getDestination(Session JavaDoc session) throws JMSException JavaDoc{
35         String JavaDoc queueName="QUEUE" + getClass().getName();
36         return session.createQueue(queueName);
37     }
38
39     protected Connection JavaDoc getConsumerConnection(ConnectionFactory JavaDoc fac) throws JMSException JavaDoc{
40         Connection JavaDoc connection=fac.createConnection();
41         connection.setClientID("testConsumer");
42         connection.start();
43         return connection;
44     }
45
46     protected MessageConsumer JavaDoc getConsumer(Connection JavaDoc connection) throws Exception JavaDoc{
47         Session JavaDoc consumerSession=connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
48         Destination JavaDoc dest = getDestination(consumerSession);
49         MessageConsumer JavaDoc consumer=consumerSession.createConsumer(dest);
50         return consumer;
51     }
52     
53     
54     protected void configureBroker(BrokerService answer) throws Exception JavaDoc{
55         PolicyEntry policy = new PolicyEntry();
56         policy.setPendingQueuePolicy(new StorePendingQueueMessageStoragePolicy());
57         PolicyMap pMap = new PolicyMap();
58         pMap.setDefaultEntry(policy);
59         answer.setDestinationPolicy(pMap);
60         answer.setDeleteAllMessagesOnStartup(true);
61         answer.addConnector(bindAddress);
62         answer.setDeleteAllMessagesOnStartup(true);
63     }
64 }
65
Popular Tags