broker = new BrokerService();
broker.setDataDirectory("target" + File.separator + "activemq-data");
broker.setPersistent(true);
broker.setDeleteAllMessagesOnStartup(true);
PolicyEntry policy = new PolicyEntry();
policy.setTopic(">");
policy.setProducerFlowControl(false);
policy.setMemoryLimit(1 * 1024 * 1024);
policy.setPendingSubscriberPolicy(new FilePendingSubscriberMessageStoragePolicy());
policy.setSubscriptionRecoveryPolicy(new LastImageSubscriptionRecoveryPolicy());
policy.setExpireMessagesPeriod(500);
List<PolicyEntry> entries = new ArrayList<PolicyEntry>();
entries.add(policy);
PolicyMap pMap = new PolicyMap();
pMap.setPolicyEntries(entries);