示例#1
0
  /** @throws Exception */
  private void printJournal() throws Exception {
    NIOSequentialFileFactory factory = new NIOSequentialFileFactory(getJournalDir());
    JournalImpl journal =
        new JournalImpl(
            HornetQDefaultConfiguration.getDefaultJournalFileSize(),
            2,
            0,
            0,
            factory,
            "hornetq-data",
            "hq",
            100);

    ArrayList<RecordInfo> records = new ArrayList<RecordInfo>();
    ArrayList<PreparedTransactionInfo> transactions = new ArrayList<PreparedTransactionInfo>();

    journal.start();
    journal.load(records, transactions, null);

    //      System.out.println("===============================================");
    //      System.out.println("Journal records at the end:");
    //
    //      for (RecordInfo record : records)
    //      {
    //         System.out.println(record.id + ", update = " + record.isUpdate);
    //      }
    journal.stop();
  }
示例#2
0
  /**
   * This will simulate what would happen with topic creationg where a single record is supposed to
   * be created on the journal
   *
   * @throws Exception
   */
  @Test
  public void testDuplicateDestinationsOnTopic() throws Exception {
    for (int i = 0; i < 5; i++) {
      if (server.locateQueue(SimpleString.toSimpleString("jms.topic.tt")) == null) {
        server.createQueue(
            SimpleString.toSimpleString("jms.topic.tt"),
            SimpleString.toSimpleString("jms.topic.tt"),
            SimpleString.toSimpleString(HornetQServerImpl.GENERIC_IGNORED_FILTER),
            true,
            false);
      }

      server.stop();

      SequentialFileFactory messagesFF = new NIOSequentialFileFactory(getBindingsDir(), null);

      JournalImpl messagesJournal =
          new JournalImpl(1024 * 1024, 2, 0, 0, messagesFF, "hornetq-bindings", "bindings", 1);

      messagesJournal.start();

      LinkedList<RecordInfo> infos = new LinkedList<RecordInfo>();

      messagesJournal.load(infos, null, null);

      int bindings = 0;
      for (RecordInfo info : infos) {
        if (info.getUserRecordType() == JournalRecordIds.QUEUE_BINDING_RECORD) {
          bindings++;
        }
      }
      assertEquals(1, bindings);

      System.out.println("Bindings: " + bindings);
      messagesJournal.stop();
      if (i < 4) server.start();
    }
  }