public Exchange getExchange(AMQShortString name) {
   if ((name == null) || name.length() == 0) {
     return getDefaultExchange();
   } else {
     return _exchangeMap.get(name);
   }
 }
Example #2
0
 /** @see #createAMQQueueImpl(String, boolean, String, boolean, boolean, VirtualHost, Map) */
 public static AMQQueue createAMQQueueImpl(
     AMQShortString name,
     boolean durable,
     AMQShortString owner,
     boolean autoDelete,
     boolean exclusive,
     VirtualHost virtualHost,
     final FieldTable arguments)
     throws AMQException {
   return createAMQQueueImpl(
       name == null ? null : name.toString(),
       durable,
       owner == null ? null : owner.toString(),
       autoDelete,
       exclusive,
       virtualHost,
       FieldTable.convertToMap(arguments));
 }
Example #3
0
  public static AMQTopic createDurableTopic(
      Topic topic, String subscriptionName, AMQConnection connection) throws JMSException {
    if (topic instanceof AMQDestination && topic instanceof javax.jms.Topic) {
      AMQDestination qpidTopic = (AMQDestination) topic;
      if (qpidTopic.getDestSyntax() == DestSyntax.ADDR) {
        try {
          AMQTopic t = new AMQTopic(qpidTopic.getAddress());
          AMQShortString queueName = getDurableTopicQueueName(subscriptionName, connection);
          // link is never null if dest was created using an address string.
          t.getLink().setName(queueName.asString());
          t.getSourceNode().setAutoDelete(false);
          t.getSourceNode().setDurable(true);

          // The legacy fields are also populated just in case.
          t.setQueueName(queueName);
          t.setAutoDelete(false);
          t.setDurable(true);
          return t;
        } catch (Exception e) {
          JMSException ex = new JMSException("Error creating durable topic");
          ex.initCause(e);
          ex.setLinkedException(e);
          throw ex;
        }
      } else {
        return new AMQTopic(
            qpidTopic.getExchangeName(),
            qpidTopic.getRoutingKey(),
            false,
            getDurableTopicQueueName(subscriptionName, connection),
            true);
      }
    } else {
      throw new InvalidDestinationException(
          "The destination object used is not from this provider or of type javax.jms.Topic");
    }
  }
  public void unregisterExchange(AMQShortString name, boolean inUse) throws AMQException {
    // Check access
    if (!_host.getSecurityManager().authoriseDelete(_exchangeMap.get(name))) {
      throw new AMQSecurityException();
    }

    // TODO: check inUse argument

    Exchange e = _exchangeMap.remove(name);
    _exchangeMapStr.remove(name.toString());
    if (e != null) {
      if (e.isDurable()) {
        getDurableConfigurationStore().removeExchange(e);

        // tell Andes Kernel to remove exchange
        QpidAMQPBridge.getInstance().deleteExchange(e);
      }
      e.close();
    } else {
      throw new AMQException("Unknown exchange " + name);
    }
  }
Example #5
0
  public static AMQQueue createAMQQueueImpl(
      String queueName,
      boolean durable,
      String owner,
      boolean autoDelete,
      boolean exclusive,
      VirtualHost virtualHost,
      Map<String, Object> arguments)
      throws AMQSecurityException {
    // Access check
    if (!virtualHost
        .getSecurityManager()
        .authoriseCreateQueue(
            autoDelete, durable, exclusive, null, null, new AMQShortString(queueName), owner)) {
      String description = "Permission denied: queue-name '" + queueName + "'";
      throw new AMQSecurityException(description);
    }

    int priorities = 1;
    String conflationKey = null;
    if (arguments != null) {
      if (arguments.containsKey(QPID_LAST_VALUE_QUEUE)
          || arguments.containsKey(QPID_LAST_VALUE_QUEUE_KEY)) {
        conflationKey = (String) arguments.get(QPID_LAST_VALUE_QUEUE_KEY);
        if (conflationKey == null) {
          conflationKey = QPID_LVQ_KEY;
        }
      } else if (arguments.containsKey(X_QPID_PRIORITIES.toString())) {
        Object prioritiesObj = arguments.get(X_QPID_PRIORITIES.toString());
        if (prioritiesObj instanceof Number) {
          priorities = ((Number) prioritiesObj).intValue();
        }
      }
    }

    AMQQueue q;
    if (conflationKey != null) {
      q =
          new ConflationQueue(
              queueName,
              durable,
              owner,
              autoDelete,
              exclusive,
              virtualHost,
              arguments,
              conflationKey);
    } else if (priorities > 1) {
      q =
          new AMQPriorityQueue(
              queueName, durable, owner, autoDelete, exclusive, virtualHost, priorities, arguments);
    } else {
      q =
          new SimpleAMQQueue(
              queueName, durable, owner, autoDelete, exclusive, virtualHost, arguments);
    }

    // Register the new queue
    virtualHost.getQueueRegistry().registerQueue(q);
    q.configure(virtualHost.getConfiguration().getQueueConfiguration(queueName));

    if (arguments != null) {
      for (QueueProperty p : DECLAREABLE_PROPERTIES) {
        if (arguments.containsKey(p.getArgumentName().toString())) {
          p.setPropertyValue(q, arguments.get(p.getArgumentName().toString()));
        }
      }
    }

    return q;
  }