Exemplo n.º 1
0
  @Override
  public CompositeData[] browse(String filterStr) throws Exception {
    checkStarted();

    clearIO();
    try {
      int pageSize =
          addressSettingsRepository
              .getMatch(queue.getName().toString())
              .getManagementBrowsePageSize();
      int currentPageSize = 0;
      ArrayList<CompositeData> c = new ArrayList<>();
      Filter filter = FilterImpl.createFilter(filterStr);
      queue.flushExecutor();
      try (LinkedListIterator<MessageReference> iterator = queue.totalIterator()) {
        while (iterator.hasNext() && currentPageSize++ < pageSize) {
          MessageReference ref = iterator.next();
          if (filter == null || filter.match(ref.getMessage())) {
            c.add(OpenTypeSupport.convert(ref));
          }
        }
        CompositeData[] rc = new CompositeData[c.size()];
        c.toArray(rc);
        return rc;
      }
    } catch (ActiveMQException e) {
      throw new IllegalStateException(e.getMessage());
    } finally {
      blockOnIO();
    }
  }
  @Override
  public List<PagingStore> reloadStores(
      final HierarchicalRepository<AddressSettings> addressSettingsRepository) throws Exception {
    File[] files = directory.listFiles();

    if (files == null) {
      return Collections.<PagingStore>emptyList();
    } else {
      ArrayList<PagingStore> storesReturn = new ArrayList<>(files.length);

      for (File file : files) {

        final String guid = file.getName();

        final File addressFile = new File(file, PagingStoreFactoryNIO.ADDRESS_FILE);

        if (!addressFile.exists()) {
          ActiveMQServerLogger.LOGGER.pageStoreFactoryNoIdFile(
              file.toString(), PagingStoreFactoryNIO.ADDRESS_FILE);
          continue;
        }

        BufferedReader reader =
            new BufferedReader(new InputStreamReader(new FileInputStream(addressFile)));

        String addressString;

        try {
          addressString = reader.readLine();
        } finally {
          reader.close();
        }

        SimpleString address = new SimpleString(addressString);

        SequentialFileFactory factory = newFileFactory(guid);

        AddressSettings settings = addressSettingsRepository.getMatch(address.toString());

        PagingStore store =
            new PagingStoreImpl(
                address,
                scheduledExecutor,
                syncTimeout,
                pagingManager,
                storageManager,
                factory,
                this,
                address,
                settings,
                executorFactory.getExecutor(),
                syncNonTransactional);

        storesReturn.add(store);
      }

      return storesReturn;
    }
  }
Exemplo n.º 3
0
  @Override
  public String getDeadLetterAddress() {
    checkStarted();

    clearIO();
    try {
      AddressSettings addressSettings = addressSettingsRepository.getMatch(address);

      if (addressSettings != null && addressSettings.getDeadLetterAddress() != null) {
        return addressSettings.getDeadLetterAddress().toString();
      }
      return null;
    } finally {
      blockOnIO();
    }
  }