/** * @param toOtherServerPair * @throws Exception */ private void setupServer1() throws Exception { List<String> toOtherServerPair = new ArrayList<String>(); toOtherServerPair.add("toServer2"); Configuration conf1 = createDefaultConfig(0, generateInVMParams(0), InVMAcceptorFactory.class.getCanonicalName()); conf1.setSecurityEnabled(false); conf1.setJMXManagementEnabled(true); conf1.setPersistenceEnabled(false); conf1 .getConnectorConfigurations() .put( "toServer2", new TransportConfiguration( InVMConnectorFactory.class.getName(), generateInVMParams(1))); conf1 .getConnectorConfigurations() .put( "server1", new TransportConfiguration( InVMConnectorFactory.class.getName(), generateInVMParams(0))); conf1.setClustered(true); conf1 .getClusterConfigurations() .add( new ClusterConnectionConfiguration( "to-server2", "jms", "server1", 1000, true, true, MAX_HOPS, 1024, toOtherServerPair, false)); JMSConfigurationImpl jmsconfig = new JMSConfigurationImpl(); // jmsconfig.getTopicConfigurations().add(new TopicConfigurationImpl("t1", "topic/t1")); server1 = HornetQServers.newHornetQServer(conf1, false); jmsServer1 = new JMSServerManagerImpl(server1, jmsconfig); context1 = new InVMContext(); jmsServer1.setContext(context1); }
/** @throws Exception */ protected void startServer() throws Exception { Configuration conf = createDefaultConfig(false); conf.getConnectorConfigurations() .put("invm", new TransportConfiguration(INVM_CONNECTOR_FACTORY)); conf.setSecurityEnabled(false); conf.setJMXManagementEnabled(true); conf.getAcceptorConfigurations().add(new TransportConfiguration(INVM_ACCEPTOR_FACTORY)); server = HornetQServers.newHornetQServer(conf, mbeanServer, true); server.start(); serverManager = new JMSServerManagerImpl(server); serverManager.start(); ctx = new InVMNamingContext(); serverManager.setContext(ctx); serverManager.activated(); }
@Override protected void setUp() throws Exception { super.setUp(); Configuration conf = createDefaultConfig(); conf.setSecurityEnabled(false); conf.getAcceptorConfigurations().add(new TransportConfiguration(INVM_ACCEPTOR_FACTORY)); server = createServer(false, conf); jmsServer = new JMSServerManagerImpl(server); jmsServer.setContext(new NullInitialContext()); jmsServer.start(); cf1 = HornetQJMSClient.createConnectionFactoryWithoutHA( JMSFactoryType.CF, new TransportConfiguration(INVM_CONNECTOR_FACTORY)); cf2 = HornetQJMSClient.createConnectionFactoryWithoutHA( JMSFactoryType.CF, new TransportConfiguration(INVM_CONNECTOR_FACTORY)); }
@Override protected void setUp() throws Exception { super.setUp(); Configuration conf = new ConfigurationImpl(); conf.setSecurityEnabled(false); conf.setJMXManagementEnabled(true); conf.getAcceptorConfigurations() .add(new TransportConfiguration(NettyAcceptorFactory.class.getName())); server = HornetQServers.newHornetQServer(conf, false); server.start(); serverManager = new JMSServerManagerImpl(server); initialContext = new InVMContext(); serverManager.setContext(initialContext); serverManager.start(); serverManager.activated(); serverManager.createTopic(topicName, topicName); registerConnectionFactory(); }
@Test public void testPagingOverCreatedDestinationQueues() throws Exception { Configuration config = createDefaultConfig(); config.setJournalSyncNonTransactional(false); HornetQServer server = createServer( true, config, -1, -1, AddressFullMessagePolicy.BLOCK, new HashMap<String, AddressSettings>()); JMSServerManagerImpl jmsServer = new JMSServerManagerImpl(server); InVMNamingContext context = new InVMNamingContext(); jmsServer.setContext(context); jmsServer.start(); server .getHornetQServerControl() .addAddressSettings( "jms.queue.Q1", "DLQ", "DLQ", -1, false, 5, 100 * 1024, 10 * 1024, 5, 5, 1, 1000, 0, false, "PAGE", -1, 10, "KILL"); jmsServer.createQueue(true, "Q1", null, true, "/queue/Q1"); HornetQJMSConnectionFactory cf = (HornetQJMSConnectionFactory) HornetQJMSClient.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("jms.queue.Q1")); assertEquals(100 * 1024, store.getMaxSize()); assertEquals(10 * 1024, store.getPageSizeBytes()); assertEquals(AddressFullMessagePolicy.PAGE, store.getAddressFullMessagePolicy()); jmsServer.stop(); server = createServer( true, config, -1, -1, AddressFullMessagePolicy.BLOCK, new HashMap<String, AddressSettings>()); jmsServer = new JMSServerManagerImpl(server); context = new InVMNamingContext(); jmsServer.setContext(context); jmsServer.start(); AddressSettings settings = server.getAddressSettingsRepository().getMatch("jms.queue.Q1"); assertEquals(100 * 1024, settings.getMaxSizeBytes()); assertEquals(10 * 1024, settings.getPageSizeBytes()); assertEquals(AddressFullMessagePolicy.PAGE, settings.getAddressFullMessagePolicy()); store = server.getPagingManager().getPageStore(new SimpleString("jms.queue.Q1")); assertEquals(100 * 1024, store.getMaxSize()); assertEquals(10 * 1024, store.getPageSizeBytes()); assertEquals(AddressFullMessagePolicy.PAGE, store.getAddressFullMessagePolicy()); }
@Test public void testPagingOverCreatedDestinationTopics() throws Exception { Configuration config = createDefaultConfig(); config.setJournalSyncNonTransactional(false); HornetQServer server = createServer(true, config, PAGE_SIZE, -1, new HashMap<String, AddressSettings>()); JMSServerManagerImpl jmsServer = new JMSServerManagerImpl(server); InVMNamingContext context = new InVMNamingContext(); jmsServer.setContext(context); jmsServer.start(); jmsServer.createTopic(true, "tt", "/topic/TT"); server .getHornetQServerControl() .addAddressSettings( "jms.topic.TT", "DLQ", "DLQ", -1, false, 5, 1024 * 1024, 1024 * 10, 5, 5, 1, 1000, 0, false, "PAGE", -1, 10, "KILL"); HornetQJMSConnectionFactory cf = (HornetQJMSConnectionFactory) HornetQJMSClient.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("jms.topic.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.setContext(context); jmsServer.start(); AddressSettings settings = server.getAddressSettingsRepository().getMatch("jms.topic.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(); }