git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@999814 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Bosanac Dejan 2010-09-22 08:50:24 +00:00
parent f7abc1fd1e
commit acb8164bc6
1 changed files with 86 additions and 0 deletions

View File

@ -0,0 +1,86 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.activemq.usecases;
import org.apache.activemq.JmsMultipleBrokersTestSupport;
import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.command.ActiveMQQueue;
import org.apache.activemq.network.NetworkConnector;
import javax.jms.MessageConsumer;
import java.net.URI;
public class AMQ2927Test extends JmsMultipleBrokersTestSupport {
ActiveMQQueue queue = new ActiveMQQueue("TEST");
@Override
public void setUp() throws Exception {
super.setAutoFail(true);
super.setUp();
createBroker(new URI("broker:(tcp://localhost:61616)/BrokerA?persistent=true&useJmx=false&deleteAllMessagesOnStartup=true"));
createBroker(new URI("broker:(tcp://localhost:61617)/BrokerB?persistent=true&useJmx=false"));
NetworkConnector aTOb = bridgeBrokers(brokers.get("BrokerA").broker, brokers.get("BrokerB").broker, false, 2, true, true);
aTOb.addStaticallyIncludedDestination(queue);
NetworkConnector bTOa = bridgeBrokers(brokers.get("BrokerB").broker, brokers.get("BrokerA").broker, false, 2, true, true);
bTOa.addStaticallyIncludedDestination(queue);
startAllBrokers();
waitForBridgeFormation();
}
public void testFailoverRestart() throws Exception {
Thread.sleep(1000);
System.out.println("restarting broker");
restartBroker("BrokerA");
Thread.sleep(5000);
System.out.println("sending message");
sendMessages("BrokerA", queue, 1);
Thread.sleep(3000);
System.out.println("consuming message");
MessageConsumer consumerA = createConsumer("BrokerA", queue);
MessageConsumer consumerB = createConsumer("BrokerB", queue);
Thread.sleep(1000);
System.out.println("consumerA = " + getConsumerMessages("BrokerA", consumerA));
System.out.println("consumerB = " + getConsumerMessages("BrokerB", consumerB));
}
protected void restartBroker(String brokerName) throws Exception {
destroyBroker("BrokerA");
BrokerService broker = createBroker(new URI("broker:(tcp://localhost:61616)/BrokerA?persistent=true&useJmx=false"));
NetworkConnector aTOb = bridgeBrokers(brokers.get("BrokerA").broker, brokers.get("BrokerB").broker, false, 2, true, true);
aTOb.addStaticallyIncludedDestination(queue);
broker.start();
broker.waitUntilStarted();
waitForBridgeFormation();
}
}