Java Code Examples for org.apache.activemq.broker.BrokerService#deleteAllMessages()

The following examples show how to use org.apache.activemq.broker.BrokerService#deleteAllMessages() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MemoryLimitTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
protected BrokerService createBroker() throws Exception {
   BrokerService broker = new BrokerService();
   broker.getSystemUsage().getMemoryUsage().setLimit(1 * 1024 * 1024); //1MB
   broker.deleteAllMessages();

   PolicyMap policyMap = new PolicyMap();
   PolicyEntry policyEntry = new PolicyEntry();
   policyEntry.setProducerFlowControl(false);
   policyMap.put(new ActiveMQQueue(">"), policyEntry);
   broker.setDestinationPolicy(policyMap);

   LOG.info("Starting broker with persistenceAdapterChoice " + persistenceAdapterChoice.toString());
   setPersistenceAdapter(broker, persistenceAdapterChoice);
   broker.getPersistenceAdapter().deleteAllMessages();

   return broker;
}
 
Example 2
Source File: ProxyFailoverTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
protected void startRemoteBroker(boolean delete) throws Exception {
   remoteBroker = new BrokerService();
   remoteBroker.addConnector("tcp://localhost:61616");
   if (delete) {
      remoteBroker.deleteAllMessages();
   }
   remoteBroker.setUseJmx(false);
   remoteBroker.start();
   remoteBroker.waitUntilStarted();
}
 
Example 3
Source File: StoreUsageTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Override
protected BrokerService createBroker() throws Exception {
   BrokerService broker = super.createBroker();
   broker.getSystemUsage().getStoreUsage().setLimit(10 * 1024);
   broker.deleteAllMessages();
   return broker;
}
 
Example 4
Source File: JobSchedulerStoreUsageTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Override
protected BrokerService createBroker() throws Exception {
   File schedulerDirectory = new File("target/scheduler");

   IOHelper.mkdirs(schedulerDirectory);
   IOHelper.deleteChildren(schedulerDirectory);

   BrokerService broker = super.createBroker();
   broker.setSchedulerSupport(true);
   broker.setSchedulerDirectoryFile(schedulerDirectory);
   broker.getSystemUsage().getJobSchedulerUsage().setLimit(7 * 1024);
   broker.deleteAllMessages();
   return broker;
}
 
Example 5
Source File: StoreUsageLimitsTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Override
protected BrokerService createBroker() throws Exception {
   BrokerService broker = super.createBroker();
   broker.getSystemUsage().getMemoryUsage().setLimit(Long.MAX_VALUE);
   broker.getSystemUsage().setCheckLimitsLogLevel(limitsLogLevel);
   broker.deleteAllMessages();
   return broker;
}
 
Example 6
Source File: JobSchedulerBrokerShutdownTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Override
protected BrokerService createBroker() throws Exception {
   File schedulerDirectory = new File("target/scheduler");

   IOHelper.mkdirs(schedulerDirectory);
   IOHelper.deleteChildren(schedulerDirectory);

   BrokerService broker = super.createBroker();
   broker.setSchedulerSupport(true);
   broker.setDataDirectory("target");
   broker.setSchedulerDirectoryFile(schedulerDirectory);
   broker.getSystemUsage().getStoreUsage().setLimit(1 * 512);
   broker.deleteAllMessages();
   return broker;
}
 
Example 7
Source File: DispatchMultipleConsumersTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Override
protected void setUp() throws Exception {
   super.setUp();
   broker = new BrokerService();
   broker.setPersistent(true);
   broker.setUseJmx(true);
   broker.deleteAllMessages();
   broker.addConnector("tcp://localhost:0");
   broker.start();
   broker.waitUntilStarted();
   dest = new ActiveMQQueue(destinationName);
   resetCounters();
   brokerURL = broker.getTransportConnectors().get(0).getPublishableConnectString();
}
 
Example 8
Source File: Broker.java    From hazelcast-simulator with Apache License 2.0 5 votes vote down vote up
public Broker start() {
    LOGGER.info("Starting broker using brokerURL: [" + brokerURL + "]");

    try {
        broker = new BrokerService();
        broker.setPersistent(false);
        broker.deleteAllMessages();
        broker.setDeleteAllMessagesOnStartup(true);
        broker.setUseJmx(false);
        broker.getSystemUsage().getTempUsage().setLimit(USAGE_LIMIT);
        broker.getSystemUsage().getStoreUsage().setLimit(USAGE_LIMIT);
        broker.addConnector(brokerURL);

        if (username != null) {
            AuthenticationUser user = new AuthenticationUser(username, password, "producers,consumer");
            SimpleAuthenticationPlugin authenticationPlugin = new SimpleAuthenticationPlugin();
            authenticationPlugin.setAnonymousAccessAllowed(false);
            authenticationPlugin.setUsers(singletonList(user));
            broker.setPlugins(new BrokerPlugin[]{authenticationPlugin});
        }

        broker.start();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }

    LOGGER.info("Successfully started broker");
    return this;
}