use of org.apache.activemq.artemis.core.config.Configuration in project activemq-artemis by apache.
the class IsolatedTopologyTest method createServer1.
private ActiveMQServer createServer1() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put(TransportConstants.CLUSTER_CONNECTION, "cc1");
params.put(org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants.SERVER_ID_PROP_NAME, "1");
TransportConfiguration acceptor1VM1 = new TransportConfiguration(ActiveMQTestBase.INVM_ACCEPTOR_FACTORY, params, "acceptor-cc1");
params = new HashMap<>();
params.put(TransportConstants.CLUSTER_CONNECTION, "cc2");
params.put(org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants.SERVER_ID_PROP_NAME, "2");
TransportConfiguration acceptor2VM1 = new TransportConfiguration(ActiveMQTestBase.INVM_ACCEPTOR_FACTORY, params, "acceptor-cc2");
List<String> connectTo = new ArrayList<>();
connectTo.add("other-cc1");
ClusterConnectionConfiguration server1CC1 = new ClusterConnectionConfiguration().setName("cc1").setAddress("jms").setConnectorName("local-cc1").setRetryInterval(250).setConfirmationWindowSize(1024).setMessageLoadBalancingType(MessageLoadBalancingType.ON_DEMAND).setStaticConnectors(connectTo);
ArrayList<String> connectTo2 = new ArrayList<>();
connectTo2.add("other-cc2");
ClusterConnectionConfiguration server1CC2 = new ClusterConnectionConfiguration().setName("cc2").setAddress("jms").setConnectorName("local-cc2").setRetryInterval(250).setConfirmationWindowSize(1024).setMessageLoadBalancingType(MessageLoadBalancingType.ON_DEMAND).setStaticConnectors(connectTo2);
// Server1 with two acceptors, each acceptor on a different cluster connection
// talking to a different connector.
// i.e. two cluster connections isolated on the same node
Configuration config1 = createBasicConfig(1).addConnectorConfiguration("local-cc1", createInVMTransportConnectorConfig(1, "local-cc1")).addConnectorConfiguration("local-cc2", createInVMTransportConnectorConfig(2, "local-cc2")).addConnectorConfiguration("other-cc1", createInVMTransportConnectorConfig(3, "other-cc1")).addConnectorConfiguration("other-cc2", createInVMTransportConnectorConfig(4, "other-cc2")).addAcceptorConfiguration(acceptor1VM1).addAcceptorConfiguration(acceptor2VM1).addClusterConfiguration(server1CC1).addClusterConfiguration(server1CC2);
return createServer(false, config1);
}
use of org.apache.activemq.artemis.core.config.Configuration in project activemq-artemis by apache.
the class NonHATopologyTest method internalTest.
public void internalTest(boolean isNetty) throws Exception {
ActiveMQServer server = null;
ServerLocatorInternal locator = null;
try {
server = createServer(false, isNetty);
if (!isNetty) {
server.getConfiguration().getAcceptorConfigurations().add(new TransportConfiguration(NETTY_ACCEPTOR_FACTORY));
server.getConfiguration().getConnectorConfigurations().put("netty", new TransportConfiguration(NETTY_CONNECTOR_FACTORY));
ArrayList<String> list = new ArrayList<>();
list.add("netty");
Configuration config = server.getConfiguration();
config.getClusterConfigurations().add(new ClusterConnectionConfiguration().setName("tst").setAddress("jms").setConnectorName("netty").setRetryInterval(1000).setConfirmationWindowSize(1000).setMessageLoadBalancingType(MessageLoadBalancingType.ON_DEMAND).setStaticConnectors(list).setAllowDirectConnectionsOnly(true));
}
server.start();
locator = (ServerLocatorInternal) createNonHALocator(isNetty);
ClientSessionFactory factory = createSessionFactory(locator);
Topology topology = locator.getTopology();
assertEquals(1, topology.getMembers().size());
factory.close();
TopologyMemberImpl member = topology.getMembers().iterator().next();
if (isNetty) {
assertEquals(NettyConnectorFactory.class.getName(), member.getLive().getFactoryClassName());
} else {
assertEquals(InVMConnectorFactory.class.getName(), member.getLive().getFactoryClassName());
}
} finally {
try {
locator.close();
} catch (Exception ignored) {
}
try {
server.stop();
} catch (Exception ignored) {
}
server = null;
locator = null;
}
}
use of org.apache.activemq.artemis.core.config.Configuration in project activemq-artemis by apache.
the class ShutdownOnCriticalIOErrorMoveNextTest method createServer.
ActiveMQServer createServer(String folder) throws Exception {
final AtomicBoolean blocked = new AtomicBoolean(false);
Configuration conf = createConfig(folder);
ActiveMQSecurityManager securityManager = new ActiveMQJAASSecurityManager(InVMLoginModule.class.getName(), new SecurityConfiguration());
conf.setPersistenceEnabled(true);
ActiveMQServer server = new ActiveMQServerImpl(conf, securityManager) {
@Override
protected StorageManager createStorageManager() {
JournalStorageManager storageManager = new JournalStorageManager(conf, getCriticalAnalyzer(), executorFactory, scheduledPool, ioExecutorFactory, shutdownOnCriticalIO) {
@Override
protected Journal createMessageJournal(Configuration config, IOCriticalErrorListener criticalErrorListener, int fileSize) {
return new JournalImpl(ioExecutorFactory, fileSize, config.getJournalMinFiles(), config.getJournalPoolFiles(), config.getJournalCompactMinFiles(), config.getJournalCompactPercentage(), config.getJournalFileOpenTimeout(), journalFF, "activemq-data", "amq", journalFF.getMaxIO(), 0, criticalErrorListener) {
@Override
protected void moveNextFile(boolean scheduleReclaim) throws Exception {
super.moveNextFile(scheduleReclaim);
if (blocked.get()) {
throw new IllegalStateException("forcibly down");
}
}
};
}
@Override
public void storeMessage(Message message) throws Exception {
super.storeMessage(message);
blocked.set(true);
}
};
this.getCriticalAnalyzer().add(storageManager);
return storageManager;
}
};
return server;
}
use of org.apache.activemq.artemis.core.config.Configuration in project activemq-artemis by apache.
the class AMQPToOpenwireTest method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
server = createServer(true, true);
server.start();
server.waitForActivation(10, TimeUnit.SECONDS);
Configuration serverConfig = server.getConfiguration();
serverConfig.getAddressesSettings().put("#", new AddressSettings().setAutoCreateQueues(false).setAutoCreateAddresses(false).setDeadLetterAddress(new SimpleString("ActiveMQ.DLQ")));
serverConfig.setSecurityEnabled(false);
coreQueue = new SimpleString(queueName);
server.createQueue(coreQueue, RoutingType.ANYCAST, coreQueue, null, false, false);
qpidfactory = new JmsConnectionFactory("amqp://localhost:61616");
}
use of org.apache.activemq.artemis.core.config.Configuration in project activemq-artemis by apache.
the class CriticalSimpleTest method testCriticalOff.
@Test
public void testCriticalOff() throws Exception {
Configuration configuration = createDefaultConfig(false);
configuration.setCriticalAnalyzerCheckPeriod(10).setCriticalAnalyzer(false);
ActiveMQServer server = createServer(false, configuration, AddressSettings.DEFAULT_PAGE_SIZE, AddressSettings.DEFAULT_MAX_SIZE_BYTES);
server.start();
try {
server.getCriticalAnalyzer().add(new CriticalComponent() {
@Override
public boolean isExpired(long timeout) {
return true;
}
});
Wait.waitFor(() -> !server.isStarted(), 500, 10);
Assert.assertTrue(server.isStarted());
} finally {
server.stop();
}
}
Aggregations