Examples of InVMContext


Examples of org.hornetq.tests.unit.util.InVMContext

      config.setJournalSyncNonTransactional(false);

      HornetQServer server = createServer(true, config, -1, -1, AddressFullMessagePolicy.BLOCK, new HashMap<String, AddressSettings>());

      JMSServerManagerImpl jmsServer = new JMSServerManagerImpl(server);
      InVMContext context = new InVMContext();
      jmsServer.setContext(context);
      jmsServer.start();

      server.getHornetQServerControl().addAddressSettings("jms.queue.Q1",
                                                          "DLQ",
                                                          "DLQ",
                                                          false,
                                                          5,
                                                          100 * 1024,
                                                          10 * 1024,
                                                          5,
                                                          5,
                                                          0,
                                                          false,
                                                          "PAGE");

      jmsServer.createQueue(true, "Q1", null, true, "/queue/Q1");

      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);
      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 InVMContext();
      jmsServer.setContext(context);
      jmsServer.start();

      AddressSettings settings = server.getAddressSettingsRepository().getMatch("jms.queue.Q1");

View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.