use of org.apache.activemq.artemis.core.registry.JndiBindingRegistry in project activemq-artemis by apache.
the class PagingOrderTest method testPagingOverCreatedDestinationTopics.
@Test
public void testPagingOverCreatedDestinationTopics() throws Exception {
Configuration config = createDefaultInVMConfig().setJournalSyncNonTransactional(false);
ActiveMQServer server = createServer(true, config, PAGE_SIZE, -1, new HashMap<String, AddressSettings>());
JMSServerManagerImpl jmsServer = new JMSServerManagerImpl(server);
InVMNamingContext context = new InVMNamingContext();
jmsServer.setRegistry(new JndiBindingRegistry(context));
jmsServer.start();
jmsServer.createTopic(true, "tt", "/topic/TT");
server.getActiveMQServerControl().addAddressSettings("TT", "DLQ", "DLQ", -1, false, 5, 1024 * 1024, 1024 * 10, 5, 5, 1, 1000, 0, false, "PAGE", -1, 10, "KILL", true, true, true, true);
ActiveMQJMSConnectionFactory cf = (ActiveMQJMSConnectionFactory) ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, new TransportConfiguration(INVM_CONNECTOR_FACTORY));
Connection conn = cf.createConnection();
conn.setClientID("tst");
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
Topic topic = (Topic) context.lookup("/topic/TT");
sess.createDurableSubscriber(topic, "t1");
MessageProducer prod = sess.createProducer(topic);
prod.setDeliveryMode(DeliveryMode.PERSISTENT);
TextMessage txt = sess.createTextMessage("TST");
prod.send(txt);
PagingStore store = server.getPagingManager().getPageStore(new SimpleString("TT"));
assertEquals(1024 * 1024, store.getMaxSize());
assertEquals(10 * 1024, store.getPageSizeBytes());
jmsServer.stop();
server = createServer(true, config, PAGE_SIZE, -1, new HashMap<String, AddressSettings>());
jmsServer = new JMSServerManagerImpl(server);
context = new InVMNamingContext();
jmsServer.setRegistry(new JndiBindingRegistry(context));
jmsServer.start();
AddressSettings settings = server.getAddressSettingsRepository().getMatch("TT");
assertEquals(1024 * 1024, settings.getMaxSizeBytes());
assertEquals(10 * 1024, settings.getPageSizeBytes());
assertEquals(AddressFullMessagePolicy.PAGE, settings.getAddressFullMessagePolicy());
store = server.getPagingManager().getPageStore(new SimpleString("TT"));
conn.close();
server.stop();
}
use of org.apache.activemq.artemis.core.registry.JndiBindingRegistry in project activemq-artemis by apache.
the class PagingOrderTest method testPagingOverCreatedDestinationQueues.
@Test
public void testPagingOverCreatedDestinationQueues() throws Exception {
Configuration config = createDefaultInVMConfig().setJournalSyncNonTransactional(false);
ActiveMQServer server = createServer(true, config, -1, -1, new HashMap<String, AddressSettings>());
server.getAddressSettingsRepository().getMatch("#").setAddressFullMessagePolicy(AddressFullMessagePolicy.BLOCK);
JMSServerManagerImpl jmsServer = new JMSServerManagerImpl(server);
InVMNamingContext context = new InVMNamingContext();
jmsServer.setRegistry(new JndiBindingRegistry(context));
jmsServer.start();
server.getActiveMQServerControl().addAddressSettings("Q1", "DLQ", "DLQ", -1, false, 5, 100 * 1024, 10 * 1024, 5, 5, 1, 1000, 0, false, "PAGE", -1, 10, "KILL", true, true, true, true);
jmsServer.createQueue(true, "Q1", null, true, "/queue/Q1");
ActiveMQJMSConnectionFactory cf = (ActiveMQJMSConnectionFactory) ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, new TransportConfiguration(INVM_CONNECTOR_FACTORY));
conn = cf.createConnection();
conn.setClientID("tst");
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
javax.jms.Queue queue = (javax.jms.Queue) context.lookup("/queue/Q1");
MessageProducer prod = sess.createProducer(queue);
prod.setDeliveryMode(DeliveryMode.PERSISTENT);
BytesMessage bmt = sess.createBytesMessage();
bmt.writeBytes(new byte[1024]);
for (int i = 0; i < 500; i++) {
prod.send(bmt);
}
PagingStore store = server.getPagingManager().getPageStore(new SimpleString("Q1"));
assertEquals(100 * 1024, store.getMaxSize());
assertEquals(10 * 1024, store.getPageSizeBytes());
assertEquals(AddressFullMessagePolicy.PAGE, store.getAddressFullMessagePolicy());
jmsServer.stop();
server = createServer(true, config, -1, -1, new HashMap<String, AddressSettings>());
server.getAddressSettingsRepository().getMatch("#").setAddressFullMessagePolicy(AddressFullMessagePolicy.BLOCK);
jmsServer = new JMSServerManagerImpl(server);
context = new InVMNamingContext();
jmsServer.setRegistry(new JndiBindingRegistry(context));
jmsServer.start();
AddressSettings settings = server.getAddressSettingsRepository().getMatch("Q1");
assertEquals(100 * 1024, settings.getMaxSizeBytes());
assertEquals(10 * 1024, settings.getPageSizeBytes());
assertEquals(AddressFullMessagePolicy.PAGE, settings.getAddressFullMessagePolicy());
store = server.getPagingManager().getPageStore(new SimpleString("Q1"));
assertEquals(100 * 1024, store.getMaxSize());
assertEquals(10 * 1024, store.getPageSizeBytes());
assertEquals(AddressFullMessagePolicy.PAGE, store.getAddressFullMessagePolicy());
}
use of org.apache.activemq.artemis.core.registry.JndiBindingRegistry in project activemq-artemis by apache.
the class JMSFailoverListenerTest method startServers.
/**
* @throws Exception
*/
protected void startServers() throws Exception {
NodeManager nodeManager = new InVMNodeManager(false);
backuptc = new TransportConfiguration(INVM_CONNECTOR_FACTORY, backupParams);
livetc = new TransportConfiguration(INVM_CONNECTOR_FACTORY);
liveAcceptortc = new TransportConfiguration(INVM_ACCEPTOR_FACTORY);
backupAcceptortc = new TransportConfiguration(INVM_ACCEPTOR_FACTORY, backupParams);
backupParams.put(TransportConstants.SERVER_ID_PROP_NAME, 1);
backupConf = createBasicConfig().addAcceptorConfiguration(backupAcceptortc).addConnectorConfiguration(livetc.getName(), livetc).addConnectorConfiguration(backuptc.getName(), backuptc).setJournalType(getDefaultJournalType()).addAcceptorConfiguration(new TransportConfiguration(INVM_ACCEPTOR_FACTORY, backupParams)).setBindingsDirectory(getBindingsDir()).setJournalMinFiles(2).setJournalDirectory(getJournalDir()).setPagingDirectory(getPageDir()).setLargeMessagesDirectory(getLargeMessagesDir()).setPersistenceEnabled(true).setHAPolicyConfiguration(new SharedStoreSlavePolicyConfiguration()).addClusterConfiguration(basicClusterConnectionConfig(backuptc.getName(), livetc.getName()));
backupServer = addServer(new InVMNodeManagerServer(backupConf, nodeManager));
backupJMSServer = new JMSServerManagerImpl(backupServer);
backupJMSServer.setRegistry(new JndiBindingRegistry(ctx2));
backupJMSServer.getActiveMQServer().setIdentity("JMSBackup");
log.info("Starting backup");
backupJMSServer.start();
liveConf = createBasicConfig().setJournalDirectory(getJournalDir()).setBindingsDirectory(getBindingsDir()).addAcceptorConfiguration(liveAcceptortc).setJournalType(getDefaultJournalType()).setBindingsDirectory(getBindingsDir()).setJournalMinFiles(2).setJournalDirectory(getJournalDir()).setPagingDirectory(getPageDir()).setLargeMessagesDirectory(getLargeMessagesDir()).addConnectorConfiguration(livetc.getName(), livetc).setPersistenceEnabled(true).setHAPolicyConfiguration(new SharedStoreMasterPolicyConfiguration()).addClusterConfiguration(basicClusterConnectionConfig(livetc.getName()));
liveServer = addServer(new InVMNodeManagerServer(liveConf, nodeManager));
liveJMSServer = new JMSServerManagerImpl(liveServer);
liveJMSServer.setRegistry(new JndiBindingRegistry(ctx1));
liveJMSServer.getActiveMQServer().setIdentity("JMSLive");
log.info("Starting life");
liveJMSServer.start();
JMSUtil.waitForServer(backupServer);
}
use of org.apache.activemq.artemis.core.registry.JndiBindingRegistry in project activemq-artemis by apache.
the class ManualReconnectionToSingleServerTest method setUp.
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
@Override
@Before
public void setUp() throws Exception {
super.setUp();
context = new InVMNamingContext();
server = createServer(false, createDefaultNettyConfig());
JMSConfiguration configuration = new JMSConfigurationImpl();
serverManager = new JMSServerManagerImpl(server, configuration);
serverManager.setRegistry(new JndiBindingRegistry(context));
configuration.getQueueConfigurations().add(new JMSQueueConfigurationImpl().setName(QUEUE_NAME).setBindings(QUEUE_NAME));
ArrayList<TransportConfiguration> configs = new ArrayList<>();
configs.add(new TransportConfiguration(NETTY_CONNECTOR_FACTORY));
ConnectionFactoryConfiguration cfConfig = new ConnectionFactoryConfigurationImpl().setName("cf").setConnectorNames(registerConnectors(server, configs)).setBindings("/cf").setRetryInterval(1000).setReconnectAttempts(-1);
configuration.getConnectionFactoryConfigurations().add(cfConfig);
serverManager.start();
listener = new Listener();
exceptionLatch = new CountDownLatch(1);
reconnectionLatch = new CountDownLatch(1);
allMessagesReceived = new CountDownLatch(1);
}
use of org.apache.activemq.artemis.core.registry.JndiBindingRegistry in project activemq-artemis by apache.
the class RemoteConnectionStressTest method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
mbeanServer = MBeanServerFactory.createMBeanServer();
server = addServer(ActiveMQServers.newActiveMQServer(createDefaultNettyConfig(), mbeanServer, false));
InVMNamingContext namingContext = new InVMNamingContext();
jmsServer = new JMSServerManagerImpl(server);
jmsServer.setRegistry(new JndiBindingRegistry(namingContext));
jmsServer.start();
jmsServer.createQueue(true, "SomeQueue", null, true, "/jms/SomeQueue");
}
Aggregations