本文整理汇总了Java中org.apache.activemq.store.memory.MemoryPersistenceAdapter类的典型用法代码示例。如果您正苦于以下问题:Java MemoryPersistenceAdapter类的具体用法?Java MemoryPersistenceAdapter怎么用?Java MemoryPersistenceAdapter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MemoryPersistenceAdapter类属于org.apache.activemq.store.memory包,在下文中一共展示了MemoryPersistenceAdapter类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startBroker
import org.apache.activemq.store.memory.MemoryPersistenceAdapter; //导入依赖的package包/类
@Before
public void startBroker() throws Exception {
broker = new BrokerService();
broker.setUseJmx(false);
broker.setPersistenceAdapter(new MemoryPersistenceAdapter());
broker.addConnector(BROKER_URL);
broker.setBrokerName("localhost");
broker.setPopulateJMSXUserID(true);
broker.setUseAuthenticatedPrincipalForJMSXUserID(true);
// enable authentication
List<AuthenticationUser> users = new ArrayList<>();
// username and password to use to connect to the broker.
// This user has users privilege (able to browse, consume, produce, list destinations)
users.add(new AuthenticationUser(USERNAME, PASSWORD, "users"));
SimpleAuthenticationPlugin plugin = new SimpleAuthenticationPlugin(users);
BrokerPlugin[] plugins = new BrokerPlugin[]{ plugin };
broker.setPlugins(plugins);
broker.start();
// create JMS connection factory
connectionFactory = new ActiveMQConnectionFactory(BROKER_URL);
connectionFactoryWithoutPrefetch =
new ActiveMQConnectionFactory(BROKER_URL + "?jms.prefetchPolicy.all=0");
}
示例2: run
import org.apache.activemq.store.memory.MemoryPersistenceAdapter; //导入依赖的package包/类
public void run() {
try {
BrokerService broker = new BrokerService();
synchronized (this) {
broker.setPersistenceAdapter(new MemoryPersistenceAdapter());
broker.setTmpDataDirectory(new File("./target"));
broker.addConnector(brokerUrl);
broker.start();
Thread.sleep(200);
notifyAll();
}
synchronized (this) {
while (!shutdownBroker) {
wait(1000);
}
}
broker.stop();
broker = null;
} catch (Exception e) {
exception = e;
e.printStackTrace();
}
}
示例3: run
import org.apache.activemq.store.memory.MemoryPersistenceAdapter; //导入依赖的package包/类
public void run() {
try {
BrokerService broker = new BrokerService();
synchronized (this) {
broker.setPersistenceAdapter(new MemoryPersistenceAdapter());
broker.setTmpDataDirectory(new File("./target"));
broker.addConnector(brokerUrl);
broker.start();
Thread.sleep(200);
notifyAll();
}
synchronized (this) {
while (!shutdownBroker) {
wait(1000);
}
}
broker.stop();
} catch (Exception e) {
exception = e;
e.printStackTrace();
}
}
示例4: EmbeddedActiveMQBroker
import org.apache.activemq.store.memory.MemoryPersistenceAdapter; //导入依赖的package包/类
public EmbeddedActiveMQBroker(String brokerId) {
if ((brokerId == null) || (brokerId.isEmpty())) {
throw new IllegalArgumentException("brokerId is empty");
}
this.brokerId = brokerId;
tcpConnectorUri = "tcp://localhost:" + AvailablePortFinder.getNextAvailable();
brokerService = new BrokerService();
brokerService.setBrokerId(brokerId);
brokerService.setPersistent(false);
brokerService.setUseJmx(false);
try {
brokerService.setPersistenceAdapter(new MemoryPersistenceAdapter());
brokerService.addConnector(tcpConnectorUri);
} catch (Exception e) {
throw new RuntimeException("Problem creating brokerService", e);
}
}
示例5: EmbeddedActiveMQBroker
import org.apache.activemq.store.memory.MemoryPersistenceAdapter; //导入依赖的package包/类
public EmbeddedActiveMQBroker(String brokerId) {
Validate.notEmpty(brokerId, "brokerId is empty");
this.brokerId = brokerId;
tcpConnectorUri = "tcp://localhost:" + AvailablePortFinder.getNextAvailable();
brokerService = new BrokerService();
brokerService.setBrokerId(brokerId);
brokerService.setPersistent(false);
brokerService.setUseJmx(false);
try {
brokerService.setPersistenceAdapter(new MemoryPersistenceAdapter());
brokerService.addConnector(tcpConnectorUri);
} catch (Exception e) {
throw new RuntimeException("Problem creating brokerService", e);
}
}
示例6: createPersistenceAdapter
import org.apache.activemq.store.memory.MemoryPersistenceAdapter; //导入依赖的package包/类
protected PersistenceAdapter createPersistenceAdapter() throws IOException {
if (isPersistent()) {
PersistenceAdapterFactory fac = getPersistenceFactory();
if (fac != null) {
return fac.createPersistenceAdapter();
} else {
try {
String clazz = "org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter";
PersistenceAdapter adaptor = (PersistenceAdapter)getClass().getClassLoader().loadClass(clazz).newInstance();
File dir = new File(getBrokerDataDirectory(),"KahaDB");
adaptor.setDirectory(dir);
return adaptor;
} catch (Throwable e) {
throw IOExceptionSupport.create(e);
}
}
} else {
return new MemoryPersistenceAdapter();
}
}
示例7: createBroker
import org.apache.activemq.store.memory.MemoryPersistenceAdapter; //导入依赖的package包/类
private BrokerService createBroker(boolean deleteAllMessages, long expireMessagesPeriod) throws Exception {
BrokerService broker = new BrokerService();
broker.setBrokerName("localhost");
broker.setDestinations(new ActiveMQDestination[]{destination});
broker.setPersistenceAdapter(new MemoryPersistenceAdapter());
PolicyEntry defaultPolicy = new PolicyEntry();
if (useVMCursor) {
defaultPolicy.setPendingQueuePolicy(new VMPendingQueueMessageStoragePolicy());
}
defaultPolicy.setExpireMessagesPeriod(expireMessagesPeriod);
defaultPolicy.setMaxExpirePageSize(1200);
PolicyMap policyMap = new PolicyMap();
policyMap.setDefaultEntry(defaultPolicy);
broker.setDestinationPolicy(policyMap);
broker.setDeleteAllMessagesOnStartup(deleteAllMessages);
broker.addConnector("tcp://localhost:0");
broker.start();
broker.waitUntilStarted();
return broker;
}
示例8: setupJmsBroker
import org.apache.activemq.store.memory.MemoryPersistenceAdapter; //导入依赖的package包/类
private BrokerService setupJmsBroker() throws IOException, URISyntaxException, Exception
{
//
// we want to connect to an independently running JMS broker.
final BrokerService broker = new BrokerService();
broker.setPersistenceAdapter(new MemoryPersistenceAdapter());
broker.setDataDirectory("target/activemq-data");
final TransportConnector connector = new TransportConnector();
connector.setUri(new URI("tcp://localhost:61616"));
broker.addConnector(connector);
broker.start();
return broker;
}
示例9: setupJmsBroker
import org.apache.activemq.store.memory.MemoryPersistenceAdapter; //导入依赖的package包/类
private BrokerService setupJmsBroker() throws IOException, URISyntaxException, Exception
{
//
// we want to connect to an independently running JMS broker.
final BrokerService broker = new BrokerService();
broker.setPersistenceAdapter(new MemoryPersistenceAdapter());
broker.setDataDirectory("target/activemq-data");
final TransportConnector connector = new TransportConnector();
connector.setUri(new URI(JMS_URL));
broker.addConnector(connector);
broker.start();
return broker;
}
示例10: createJmsBroker
import org.apache.activemq.store.memory.MemoryPersistenceAdapter; //导入依赖的package包/类
private BrokerService createJmsBroker() throws IOException, URISyntaxException, Exception
{
//
// we want to connect to an independently running JMS broker.
final BrokerService broker = new BrokerService();
broker.setPersistenceAdapter(new MemoryPersistenceAdapter());
broker.setDataDirectory("target/activemq-data");
final TransportConnector connector = new TransportConnector();
connector.setUri(new URI(JMS_URL));
broker.addConnector(connector);
broker.start();
return broker;
}
示例11: setPersistenceAdapter
import org.apache.activemq.store.memory.MemoryPersistenceAdapter; //导入依赖的package包/类
/**
* Sets the persistence adaptor implementation to use for this broker
*
* @throws IOException
*/
public void setPersistenceAdapter(PersistenceAdapter persistenceAdapter) throws IOException {
if (!isPersistent() && ! (persistenceAdapter instanceof MemoryPersistenceAdapter)) {
LOG.warn("persistent=\"false\", ignoring configured persistenceAdapter: {}", persistenceAdapter);
return;
}
this.persistenceAdapter = persistenceAdapter;
configureService(this.persistenceAdapter);
this.persistenceAdapter = registerPersistenceAdapterMBean(persistenceAdapter);
}
示例12: testMemoryConfig
import org.apache.activemq.store.memory.MemoryPersistenceAdapter; //导入依赖的package包/类
@Test
public void testMemoryConfig() throws Exception {
File journalFile = new File(JOURNAL_ROOT + "testMemoryConfig");
recursiveDelete(journalFile);
File derbyFile = new File(DERBY_ROOT + "testMemoryConfig");
recursiveDelete(derbyFile);
BrokerService broker;
broker = createBroker(new FileSystemResource(CONF_ROOT + "memory-example.xml"));
try {
assertEquals("Broker Config Error (brokerName)", "brokerMemoryConfigTest", broker.getBrokerName());
PersistenceAdapter adapter = broker.getPersistenceAdapter();
assertTrue("Should have created a memory persistence adapter", adapter instanceof MemoryPersistenceAdapter);
assertTrue("Should have not created a derby directory at " + derbyFile.getAbsolutePath(), !derbyFile.exists());
assertTrue("Should have not created a journal directory at " + journalFile.getAbsolutePath(), !journalFile.exists());
LOG.info("Success");
} finally {
if (broker != null) {
broker.stop();
}
}
}
示例13: setUp
import org.apache.activemq.store.memory.MemoryPersistenceAdapter; //导入依赖的package包/类
@Setup @SuppressWarnings("unused")
private void setUp() throws Exception {
broker = new BrokerService();
broker.setBrokerName(BROKER_NAME);
broker.setDataDirectory("target/activemq-data");
broker.setPersistenceAdapter(new MemoryPersistenceAdapter());
broker.start();
}
示例14: testNoDataSource
import org.apache.activemq.store.memory.MemoryPersistenceAdapter; //导入依赖的package包/类
public void testNoDataSource() throws Exception {
final BrokerService broker = BrokerFactory.createBroker(new URI(getBrokerUri(
"broker:(tcp://localhost:" + brokerPort + ")?useJmx=false")));
assertNotNull("broker is null", broker);
final PersistenceAdapter persistenceAdapter = broker.getPersistenceAdapter();
assertNotNull("persistenceAdapter is null", persistenceAdapter);
assertTrue("persistenceAdapter should be an instance of MemoryPersistenceAdapter",
persistenceAdapter instanceof MemoryPersistenceAdapter);
stopBroker(broker);
}