示例#1
0
  /**
   * Looks for a topic in the space with the same base name.
   *
   * @param baseName The base name to search for.
   * @return If a matching topic exists, that topic is returned, otherwise <code>null</code> is
   *     returned.
   */
  public JMSTopic getTopicByBaseName(String baseName) {
    JMSTopic template = new JMSTopic();
    template.setBaseName(baseName);

    JMSTopic topicFound = null;

    try {
      topicFound = (JMSTopic) space.readIfExists(template, null, 1000);
    } catch (Exception e) {
      System.err.println("Failed to get topic by base name. Base name queried: '" + baseName + "'");
      e.printStackTrace();
    }

    return topicFound;
  }
示例#2
0
  /**
   * Whether or not a topic already exists in the space with the same base name or UUID.
   *
   * @param topic The topic to check if exists
   * @param transaction The transaction in which the check will take place
   * @return <code>true</code> if a match by either base name or UUID, otherwise <code>false</code>
   */
  private boolean topicExistsInSpace(JMSTopic topic, Transaction transaction) {
    try {
      JMSTopic template = new JMSTopic();
      template.setBaseName(topic.getBaseName());
      JMSTopic topicBaseNameMatch = (JMSTopic) space.readIfExists(template, transaction, 2000);

      template = new JMSTopic();
      template.setId(topic.getId());
      JMSTopic topicIdMatch = (JMSTopic) space.readIfExists(template, transaction, 2000);

      if (topicBaseNameMatch != null || topicIdMatch != null) {
        return true;
      }
    } catch (Exception e) {
      e.printStackTrace();
    }

    return false;
  }