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());
}
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();
}
}
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);
}
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;
}
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);
}
}
Aggregations