コード例 #1
0
  @Override
  protected void setUp() throws Exception {
    super.setUp();

    setupServer2();
    setupServer1();

    jmsServer1.start();
    jmsServer1.activated();

    jmsServer2.start();
    jmsServer2.activated();

    cf1 =
        (ConnectionFactory)
            HornetQJMSClient.createConnectionFactoryWithoutHA(
                JMSFactoryType.CF,
                new TransportConfiguration(
                    InVMConnectorFactory.class.getName(), generateInVMParams(0)));
    cf2 =
        (ConnectionFactory)
            HornetQJMSClient.createConnectionFactoryWithoutHA(
                JMSFactoryType.CF,
                new TransportConfiguration(
                    InVMConnectorFactory.class.getName(), generateInVMParams(1)));
  }
コード例 #2
0
  @Override
  protected void tearDown() throws Exception {

    cf1.close();

    cf2.close();

    if (jmsServer != null && jmsServer.isStarted()) {
      jmsServer.stop();
    }

    super.tearDown();
  }
コード例 #3
0
  /** @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();
  }
コード例 #4
0
  /** @throws Exception */
  protected void stopServer() throws Exception {
    serverManager.stop();

    server.stop();

    serverManager = null;

    server = null;
  }
コード例 #5
0
  @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));
  }
コード例 #6
0
  @Override
  protected void tearDown() throws Exception {

    try {
      jmsServer2.stop();

      server2.stop();

      context2.close();
    } catch (Throwable e) {
      log.warn("Can't stop server2", e);
    }

    ((HornetQConnectionFactory) cf1).close();

    ((HornetQConnectionFactory) cf2).close();

    server2 = null;

    jmsServer2 = null;

    context2 = null;

    cf1 = null;

    try {
      jmsServer1.stop();

      server1.stop();

      context1.close();
    } catch (Throwable e) {
      log.warn("Can't stop server2", e);
    }

    server1 = null;

    jmsServer1 = null;

    context1 = null;

    super.tearDown();
  }
コード例 #7
0
ファイル: FloodServerTest.java プロジェクト: hstemmer/hornetq
  @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();
  }
コード例 #8
0
ファイル: FloodServerTest.java プロジェクト: hstemmer/hornetq
  @Override
  protected void tearDown() throws Exception {

    serverManager.stop();

    server.stop();

    server = null;

    serverManager = null;

    super.tearDown();
  }
コード例 #9
0
  /**
   * @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);
  }
コード例 #10
0
ファイル: FloodServerTest.java プロジェクト: hstemmer/hornetq
  private void registerConnectionFactory() throws Exception {
    int retryInterval = 1000;
    double retryIntervalMultiplier = 1.0;
    int reconnectAttempts = -1;
    boolean failoverOnServerShutdown = true;
    long callTimeout = 30000;

    List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs =
        new ArrayList<Pair<TransportConfiguration, TransportConfiguration>>();
    connectorConfigs.add(
        new Pair<TransportConfiguration, TransportConfiguration>(
            new TransportConfiguration(NettyConnectorFactory.class.getName()), null));

    List<String> jndiBindings = new ArrayList<String>();
    jndiBindings.add("/cf");

    serverManager.createConnectionFactory(
        "ManualReconnectionToSingleServerTest",
        connectorConfigs,
        null,
        1000,
        HornetQClient.DEFAULT_CONNECTION_TTL,
        callTimeout,
        HornetQClient.DEFAULT_CACHE_LARGE_MESSAGE_CLIENT,
        HornetQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE,
        HornetQClient.DEFAULT_CONSUMER_WINDOW_SIZE,
        HornetQClient.DEFAULT_CONSUMER_MAX_RATE,
        HornetQClient.DEFAULT_CONFIRMATION_WINDOW_SIZE,
        HornetQClient.DEFAULT_PRODUCER_WINDOW_SIZE,
        HornetQClient.DEFAULT_PRODUCER_MAX_RATE,
        false,
        false,
        false,
        HornetQClient.DEFAULT_AUTO_GROUP,
        false,
        HornetQClient.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
        HornetQClient.DEFAULT_ACK_BATCH_SIZE,
        HornetQClient.DEFAULT_ACK_BATCH_SIZE,
        HornetQClient.DEFAULT_USE_GLOBAL_POOLS,
        HornetQClient.DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE,
        HornetQClient.DEFAULT_THREAD_POOL_MAX_SIZE,
        retryInterval,
        retryIntervalMultiplier,
        1000,
        reconnectAttempts,
        failoverOnServerShutdown,
        null,
        jndiBindings);
  }
コード例 #11
0
  protected Topic createTopic(final String name) throws Exception, NamingException {
    jmsServer2.createTopic(false, name, "/topic/" + name);
    jmsServer1.createTopic(false, name, "/topic/" + name);

    return (Topic) context1.lookup("/topic/" + name);
  }
コード例 #12
0
  /**
   * @throws Exception
   * @throws NamingException
   */
  protected Queue createQueue(final String name) throws Exception, NamingException {
    jmsServer2.createQueue(false, name, null, true, "/queue/" + name);
    jmsServer1.createQueue(false, name, null, true, "/queue/" + name);

    return (Queue) context1.lookup("/queue/" + name);
  }
コード例 #13
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());
  }
コード例 #14
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();
  }