Search in sources :

Example 56 with BrokerService

use of org.apache.activemq.broker.BrokerService in project activemq-artemis by apache.

the class SpringTest method testStartFalse.

public void testStartFalse() throws Exception {
    String config = "spring-start-false.xml";
    Thread.currentThread().setContextClassLoader(SpringTest.class.getClassLoader());
    context = new ClassPathXmlApplicationContext(config);
    BrokerService broker = context.getBean(BrokerService.class);
    assertFalse("Broker is started", broker.isStarted());
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) BrokerService(org.apache.activemq.broker.BrokerService)

Example 57 with BrokerService

use of org.apache.activemq.broker.BrokerService in project activemq-artemis by apache.

the class RunBroker method main.

public static void main(String[] arg) {
    try {
        KahaDBPersistenceAdapter kahaDB = new KahaDBPersistenceAdapter();
        File dataFileDir = new File("target/test-amq-data/perfTest/kahadb");
        IOHelper.deleteChildren(dataFileDir);
        kahaDB.setDirectory(dataFileDir);
        // The setEnableJournalDiskSyncs(false) setting is a little
        // dangerous right now, as I have not verified
        // what happens if the index is updated but a journal update is
        // lost.
        // Index is going to be in consistent, but can it be repaired?
        // kaha.setEnableJournalDiskSyncs(false);
        // Using a bigger journal file size makes he take fewer spikes as it
        // is not switching files as often.
        // kaha.setJournalMaxFileLength(1024*1024*100);
        // small batch means more frequent and smaller writes
        kahaDB.setIndexWriteBatchSize(1000);
        kahaDB.setIndexCacheSize(10000);
        // do the index write in a separate thread
        // kahaDB.setEnableIndexWriteAsync(true);
        BrokerService broker = new BrokerService();
        broker.setUseJmx(false);
        // broker.setPersistenceAdapter(adaptor);
        broker.setPersistenceAdapter(kahaDB);
        // broker.setPersistent(false);
        broker.setDeleteAllMessagesOnStartup(true);
        broker.addConnector("tcp://0.0.0.0:61616");
        broker.start();
        System.err.println("Running");
        Thread.sleep(Long.MAX_VALUE);
    } catch (Throwable e) {
        e.printStackTrace();
    }
}
Also used : File(java.io.File) BrokerService(org.apache.activemq.broker.BrokerService) KahaDBPersistenceAdapter(org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter)

Example 58 with BrokerService

use of org.apache.activemq.broker.BrokerService in project activemq-artemis by apache.

the class InactiveQueueTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    broker = new BrokerService();
    // broker.setPersistenceAdapter(new KahaPersistenceAdapter(new File
    // ("TEST_STUFD")));
    /*
         * JournalPersistenceAdapterFactory factory = new
         * JournalPersistenceAdapterFactory();
         * factory.setDataDirectoryFile(broker.getDataDirectory());
         * factory.setTaskRunnerFactory(broker.getTaskRunnerFactory());
         * factory.setUseJournal(false); broker.setPersistenceFactory(factory);
         */
    broker.addConnector(ActiveMQConnectionFactory.DEFAULT_BROKER_BIND_URL);
    broker.start();
    connectionFactory = new ActiveMQConnectionFactory(ActiveMQConnectionFactory.DEFAULT_BROKER_URL);
    /*
         * Doesn't matter if you enable or disable these, so just leaving them
         * out for this test case connectionFactory.setAlwaysSessionAsync(true);
         * connectionFactory.setAsyncDispatch(true);
         */
    connectionFactory.setUseAsyncSend(true);
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) BrokerService(org.apache.activemq.broker.BrokerService)

Example 59 with BrokerService

use of org.apache.activemq.broker.BrokerService in project activemq-artemis by apache.

the class SingleBrokerVirtualDestinationsWithWildcardTest method createAndConfigureBroker.

private BrokerService createAndConfigureBroker(URI uri) throws Exception {
    BrokerService broker = createBroker(uri);
    configurePersistenceAdapter(broker);
    // make all topics virtual and consumers use the default prefix
    VirtualDestinationInterceptor virtualDestinationInterceptor = new VirtualDestinationInterceptor();
    virtualDestinationInterceptor.setVirtualDestinations(new VirtualDestination[] { new VirtualTopic() });
    DestinationInterceptor[] destinationInterceptors = new DestinationInterceptor[] { virtualDestinationInterceptor };
    broker.setDestinationInterceptors(destinationInterceptors);
    return broker;
}
Also used : VirtualTopic(org.apache.activemq.broker.region.virtual.VirtualTopic) VirtualDestinationInterceptor(org.apache.activemq.broker.region.virtual.VirtualDestinationInterceptor) DestinationInterceptor(org.apache.activemq.broker.region.DestinationInterceptor) BrokerService(org.apache.activemq.broker.BrokerService) VirtualDestinationInterceptor(org.apache.activemq.broker.region.virtual.VirtualDestinationInterceptor)

Example 60 with BrokerService

use of org.apache.activemq.broker.BrokerService in project activemq-artemis by apache.

the class ThreeBrokerQueueNetworkTest method testDuplicateQueueSubs.

public void testDuplicateQueueSubs() throws Exception {
    configureBroker(createBroker("BrokerD"));
    bridgeAllBrokers("default", 3, false);
    startAllBrokers();
    waitForBridgeFormation();
    // Setup destination
    Destination dest = createDestination("TEST.FOO", false);
    // Setup consumers
    String brokerName = "BrokerA";
    MessageConsumer consumer = createConsumer(brokerName, dest);
    // wait for advisories
    Thread.sleep(2000);
    verifyConsumerCount(brokers.get(brokerName).broker, 1, dest);
    // in a cyclic network, other brokers will get second order consumer
    // an alternative route to A via each other
    Collection<BrokerItem> brokerList = brokers.values();
    for (Iterator<BrokerItem> i = brokerList.iterator(); i.hasNext(); ) {
        BrokerService broker = i.next().broker;
        if (!brokerName.equals(broker.getBrokerName())) {
            verifyConsumerCount(broker, 5, dest);
            verifyConsumePriority(broker, ConsumerInfo.NORMAL_PRIORITY, dest);
        }
    }
    consumer.close();
    // wait for advisories
    Thread.sleep(2000);
    for (Iterator<BrokerItem> i = brokerList.iterator(); i.hasNext(); ) {
        BrokerService broker = i.next().broker;
        if (!brokerName.equals(broker.getBrokerName())) {
            logConsumerCount(broker, 0, dest);
        }
    }
    for (Iterator<BrokerItem> i = brokerList.iterator(); i.hasNext(); ) {
        BrokerService broker = i.next().broker;
        verifyConsumerCount(broker, 0, dest);
    }
}
Also used : ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination) Destination(javax.jms.Destination) MessageConsumer(javax.jms.MessageConsumer) BrokerService(org.apache.activemq.broker.BrokerService)

Aggregations

BrokerService (org.apache.activemq.broker.BrokerService)349 URI (java.net.URI)53 PolicyEntry (org.apache.activemq.broker.region.policy.PolicyEntry)45 PolicyMap (org.apache.activemq.broker.region.policy.PolicyMap)45 Test (org.junit.Test)43 ActiveMQConnectionFactory (org.apache.activemq.ActiveMQConnectionFactory)32 TransportConnector (org.apache.activemq.broker.TransportConnector)31 Before (org.junit.Before)22 File (java.io.File)20 MemoryPersistenceAdapter (org.apache.activemq.store.memory.MemoryPersistenceAdapter)17 JMSException (javax.jms.JMSException)16 JDBCPersistenceAdapter (org.apache.activemq.store.jdbc.JDBCPersistenceAdapter)14 KahaDBPersistenceAdapter (org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter)14 BrokerFactoryBean (org.apache.activemq.xbean.BrokerFactoryBean)14 NetworkConnector (org.apache.activemq.network.NetworkConnector)13 MessageConsumer (javax.jms.MessageConsumer)12 PersistenceAdapter (org.apache.activemq.store.PersistenceAdapter)12 ArrayList (java.util.ArrayList)11 Destination (javax.jms.Destination)11 ClassPathResource (org.springframework.core.io.ClassPathResource)10