private Configuration getConfiguration( String identity, BackupStrategy backupStrategy, TransportConfiguration liveConnector, TransportConfiguration liveAcceptor, TransportConfiguration... otherLiveNodes) throws Exception { Configuration configuration = createDefaultConfig(); configuration.getAcceptorConfigurations().clear(); configuration.getAcceptorConfigurations().add(liveAcceptor); configuration.getConnectorConfigurations().put(liveConnector.getName(), liveConnector); configuration.setJournalDirectory(configuration.getJournalDirectory() + identity); configuration.setBindingsDirectory(configuration.getBindingsDirectory() + identity); configuration.setLargeMessagesDirectory(configuration.getLargeMessagesDirectory() + identity); configuration.setPagingDirectory(configuration.getPagingDirectory() + identity); List<String> transportConfigurationList = new ArrayList<>(); final HAPolicy haPolicy = new HAPolicy(); for (TransportConfiguration otherLiveNode : otherLiveNodes) { configuration.getConnectorConfigurations().put(otherLiveNode.getName(), otherLiveNode); transportConfigurationList.add(otherLiveNode.getName()); haPolicy.getRemoteConnectors().add(otherLiveNode.getName()); } basicClusterConnectionConfig( configuration, liveConnector.getName(), transportConfigurationList); configuration .getQueueConfigurations() .add(new CoreQueueConfiguration("jms.queue.testQueue", "jms.queue.testQueue", null, true)); haPolicy.setPolicyType(policyType); haPolicy.setBackupStrategy(backupStrategy); haPolicy.setBackupPortOffset(100); haPolicy.setBackupRequestRetries(-1); haPolicy.setBackupRequestRetryInterval(500); haPolicy.setMaxBackups(1); haPolicy.setRequestBackup(true); configuration.setHAPolicy(haPolicy); return configuration; }
@Override protected void setUp() throws Exception { super.setUp(); Map<String, Object> acceptorParams = new HashMap<String, Object>(); acceptorParams.put(TransportConstants.SERVER_ID_PROP_NAME, 1); TransportConfiguration acceptorConfig = new TransportConfiguration( InVMAcceptorFactory.class.getName(), acceptorParams, RandomUtil.randomString()); TransportConfiguration connectorConfig = new TransportConfiguration( InVMConnectorFactory.class.getName(), acceptorParams, RandomUtil.randomString()); CoreQueueConfiguration sourceQueueConfig = new CoreQueueConfiguration( RandomUtil.randomString(), RandomUtil.randomString(), null, false); CoreQueueConfiguration targetQueueConfig = new CoreQueueConfiguration( RandomUtil.randomString(), RandomUtil.randomString(), null, false); List<String> connectors = new ArrayList<String>(); connectors.add(connectorConfig.getName()); bridgeConfig = new BridgeConfiguration( RandomUtil.randomString(), sourceQueueConfig.getName(), targetQueueConfig.getAddress(), null, null, HornetQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE, HornetQClient.DEFAULT_CLIENT_FAILURE_CHECK_PERIOD, HornetQClient.DEFAULT_CONNECTION_TTL, RandomUtil.randomPositiveLong(), HornetQClient.DEFAULT_MAX_RETRY_INTERVAL, RandomUtil.randomDouble(), RandomUtil.randomPositiveInt(), RandomUtil.randomBoolean(), RandomUtil.randomPositiveInt(), connectors, false, ConfigurationImpl.DEFAULT_CLUSTER_USER, ConfigurationImpl.DEFAULT_CLUSTER_PASSWORD); Configuration conf_1 = createBasicConfig(); conf_1.setSecurityEnabled(false); conf_1.setJMXManagementEnabled(true); conf_1.setClustered(true); conf_1.getAcceptorConfigurations().add(acceptorConfig); conf_1.getQueueConfigurations().add(targetQueueConfig); Configuration conf_0 = createBasicConfig(); conf_0.setSecurityEnabled(false); conf_0.setJMXManagementEnabled(true); conf_0.setClustered(true); conf_0 .getAcceptorConfigurations() .add(new TransportConfiguration(InVMAcceptorFactory.class.getName())); conf_0.getConnectorConfigurations().put(connectorConfig.getName(), connectorConfig); conf_0.getQueueConfigurations().add(sourceQueueConfig); conf_0.getBridgeConfigurations().add(bridgeConfig); server_1 = HornetQServers.newHornetQServer(conf_1, MBeanServerFactory.createMBeanServer(), false); addServer(server_1); server_1.start(); server_0 = HornetQServers.newHornetQServer(conf_0, mbeanServer, false); addServer(server_0); server_0.start(); }