BrokerService broker = new BrokerService();
broker.setDeleteAllMessagesOnStartup(true);
broker.addConnector("tcp://localhost:0");
PolicyMap policyMap = new PolicyMap();
PolicyEntry defaultEntry = new PolicyEntry();
defaultEntry.setPendingQueuePolicy(new FilePendingQueueMessageStoragePolicy());
defaultEntry.setCursorMemoryHighWaterMark(50);
defaultEntry.setMemoryLimit(500*1024);
defaultEntry.setProducerFlowControl(false);
policyMap.setDefaultEntry(defaultEntry);
broker.setDestinationPolicy(policyMap);