use of org.apache.activemq.artemis.core.server.cluster.ha.BackupPolicy in project activemq-artemis by apache.
the class FailoverTest method testFailBackLiveRestartsBackupIsGone.
@Test(timeout = 120000)
public void testFailBackLiveRestartsBackupIsGone() throws Exception {
locator.setFailoverOnInitialConnection(true);
createSessionFactory();
ClientSession session = createSessionAndQueue();
ClientProducer producer = addClientProducer(session.createProducer(FailoverTestBase.ADDRESS));
sendMessages(session, producer, NUM_MESSAGES);
producer.close();
session.commit();
SimpleString liveId = liveServer.getServer().getNodeID();
crash(session);
session.start();
ClientConsumer consumer = addClientConsumer(session.createConsumer(FailoverTestBase.ADDRESS));
receiveMessages(consumer);
assertNoMoreMessages(consumer);
consumer.close();
session.commit();
Assert.assertEquals("backup must be running with the same nodeID", liveId, backupServer.getServer().getNodeID());
sf.close();
backupServer.crash();
Thread.sleep(100);
Assert.assertFalse("backup is not running", backupServer.isStarted());
Assert.assertFalse("must NOT be a backup", liveServer.getServer().getHAPolicy() instanceof BackupPolicy);
adaptLiveConfigForReplicatedFailBack(liveServer);
beforeRestart(liveServer);
liveServer.start();
Assert.assertTrue("live initialized...", liveServer.getServer().waitForActivation(15, TimeUnit.SECONDS));
sf = (ClientSessionFactoryInternal) createSessionFactory(locator);
ClientSession session2 = createSession(sf, false, false);
session2.start();
ClientConsumer consumer2 = session2.createConsumer(FailoverTestBase.ADDRESS);
boolean replication = liveServer.getServer().getHAPolicy() instanceof ReplicatedPolicy;
if (replication)
receiveMessages(consumer2, 0, NUM_MESSAGES, true);
assertNoMoreMessages(consumer2);
session2.commit();
}
Aggregations