Example #1
0
  /**
   * Looks for a topic in the space with the same UUID.
   *
   * @param baseName The UUID to search for.
   * @return If a matching topic exists, that topic is returned, otherwise <code>null</code> is
   *     returned.
   */
  public JMSTopic getTopicById(UUID id) {
    JMSTopic template = new JMSTopic();
    template.setId(id);

    JMSTopic topic = null;

    try {
      topic = (JMSTopic) space.readIfExists(template, null, 1000);
    } catch (RemoteException
        | UnusableEntryException
        | TransactionException
        | InterruptedException e) {
      System.err.println("Failed to get topic by ID.  Topic ID queried: '" + id.toString() + "'");
      e.printStackTrace();
    }

    return topic;
  }
Example #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;
  }