private void createBroker(boolean delete) throws Exception {
broker = BrokerFactory.createBroker("broker:(vm://localhost)");
broker.setKeepDurableSubsActive(true);
broker.setPersistent(true);
broker.setDeleteAllMessagesOnStartup(delete);
KahaDBPersistenceAdapter kahadb = new KahaDBPersistenceAdapter();
kahadb.setDirectory(new File("activemq-data/" + getName() + "-kahadb"));
kahadb.setJournalMaxFileLength(500 * 1024);
broker.setPersistenceAdapter(kahadb);
broker.setBrokerName(getName());
// only if we pre-create the destinations
broker.setDestinations(new ActiveMQDestination[]{topic});