Search in sources :

Example 36 with Configuration

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);
}
Also used : ClusterConnectionConfiguration(org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration) Configuration(org.apache.activemq.artemis.core.config.Configuration) ClusterConnectionConfiguration(org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration)

Example 37 with Configuration

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;
    }
}
Also used : ClusterConnectionConfiguration(org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration) TopologyMemberImpl(org.apache.activemq.artemis.core.client.impl.TopologyMemberImpl) Configuration(org.apache.activemq.artemis.core.config.Configuration) ClusterConnectionConfiguration(org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) NettyConnectorFactory(org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory) ArrayList(java.util.ArrayList) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) Topology(org.apache.activemq.artemis.core.client.impl.Topology) ServerLocatorInternal(org.apache.activemq.artemis.core.client.impl.ServerLocatorInternal) ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) InVMConnectorFactory(org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory) ClientSessionFactory(org.apache.activemq.artemis.api.core.client.ClientSessionFactory)

Example 38 with Configuration

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;
}
Also used : IOCriticalErrorListener(org.apache.activemq.artemis.core.io.IOCriticalErrorListener) Configuration(org.apache.activemq.artemis.core.config.Configuration) SecurityConfiguration(org.apache.activemq.artemis.core.config.impl.SecurityConfiguration) Message(org.apache.activemq.artemis.api.core.Message) ActiveMQJAASSecurityManager(org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager) InVMLoginModule(org.apache.activemq.artemis.spi.core.security.jaas.InVMLoginModule) ActiveMQServerImpl(org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl) JournalStorageManager(org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) SecurityConfiguration(org.apache.activemq.artemis.core.config.impl.SecurityConfiguration) ActiveMQSecurityManager(org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager) JournalImpl(org.apache.activemq.artemis.core.journal.impl.JournalImpl)

Example 39 with Configuration

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");
}
Also used : AddressSettings(org.apache.activemq.artemis.core.settings.impl.AddressSettings) Configuration(org.apache.activemq.artemis.core.config.Configuration) JmsConnectionFactory(org.apache.qpid.jms.JmsConnectionFactory) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) Before(org.junit.Before)

Example 40 with Configuration

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();
    }
}
Also used : ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) CriticalComponent(org.apache.activemq.artemis.utils.critical.CriticalComponent) Configuration(org.apache.activemq.artemis.core.config.Configuration) Test(org.junit.Test)

Aggregations

Configuration (org.apache.activemq.artemis.core.config.Configuration)331 Test (org.junit.Test)143 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)120 ClientSession (org.apache.activemq.artemis.api.core.client.ClientSession)109 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)108 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)101 ClientProducer (org.apache.activemq.artemis.api.core.client.ClientProducer)93 ClientMessage (org.apache.activemq.artemis.api.core.client.ClientMessage)90 ClientConsumer (org.apache.activemq.artemis.api.core.client.ClientConsumer)81 ClientSessionFactory (org.apache.activemq.artemis.api.core.client.ClientSessionFactory)78 StoreConfiguration (org.apache.activemq.artemis.core.config.StoreConfiguration)78 DivertConfiguration (org.apache.activemq.artemis.core.config.DivertConfiguration)72 Before (org.junit.Before)59 ServerLocator (org.apache.activemq.artemis.api.core.client.ServerLocator)58 DatabaseStorageConfiguration (org.apache.activemq.artemis.core.config.storage.DatabaseStorageConfiguration)57 HashMap (java.util.HashMap)56 AddressSettings (org.apache.activemq.artemis.core.settings.impl.AddressSettings)52 ActiveMQDefaultConfiguration (org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration)35 SharedStoreMasterPolicyConfiguration (org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration)35 ActiveMQBuffer (org.apache.activemq.artemis.api.core.ActiveMQBuffer)34