@Test
  public void testCreateCF() throws Exception {
    JMSServerControl control = createJMSControl();
    control.createConnectionFactory("test", false, false, 0, "invm", "test");

    ConnectionFactoryControl controlCF = createCFControl("test");

    HornetQConnectionFactory cf = (HornetQConnectionFactory) ctx.lookup("test");

    assertFalse(cf.isCompressLargeMessage());

    controlCF.setCompressLargeMessages(true);

    cf = (HornetQConnectionFactory) ctx.lookup("test");
    assertTrue(cf.isCompressLargeMessage());

    stopServer();

    Thread.sleep(500);

    startServer();

    cf = (HornetQConnectionFactory) ctx.lookup("test");
    assertTrue(cf.isCompressLargeMessage());
  }
예제 #2
0
  @Override
  @After
  public void tearDown() throws Exception {
    checkEmpty(sourceQueue, 0);
    checkEmpty(localTargetQueue, 0);
    checkEmpty(targetQueue, 1);

    // Check no subscriptions left lying around

    checkNoSubscriptions(sourceTopic, 0);
    if (cff0 instanceof HornetQConnectionFactory) {
      ((HornetQConnectionFactory) cff0).close();
    }
    if (cff1 instanceof HornetQConnectionFactory) {
      ((HornetQConnectionFactory) cff1).close();
    }
    stopComponent(jmsServer0);
    stopComponent(jmsServer1);
    cff0 = cff1 = null;
    cff0xa = cff1xa = null;

    cf0 = cf1 = null;

    cf0xa = cf1xa = null;

    sourceQueueFactory = targetQueueFactory = localTargetQueueFactory = sourceTopicFactory = null;

    sourceQueue = targetQueue = localTargetQueue = null;

    sourceTopic = null;

    server0 = null;

    jmsServer0 = null;

    server1 = null;

    jmsServer1 = null;
    if (context0 != null) context0.close();
    context0 = null;
    if (context1 != null) context1.close();
    context1 = null;

    // Shutting down Arjuna threads
    TxControl.disable(true);

    TransactionReaper.terminate(false);
    super.tearDown();
  }
예제 #3
0
  @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());
  }
예제 #4
0
  @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();
  }