Exemple #1
0
  @Override
  protected RabbitMQEndpoint createEndpoint(
      String uri, String remaining, Map<String, Object> params) throws Exception {
    URI host = new URI("http://" + remaining);
    String hostname = host.getHost();
    int portNumber = host.getPort();
    String exchangeName = ""; // We need to support the exchange to be "" the path is empty
    if (host.getPath().trim().length() > 1) {
      exchangeName = host.getPath().substring(1);
    }

    // ConnectionFactory reference
    ConnectionFactory connectionFactory =
        resolveAndRemoveReferenceParameter(params, "connectionFactory", ConnectionFactory.class);
    @SuppressWarnings("unchecked")
    Map<String, Object> clientProperties =
        resolveAndRemoveReferenceParameter(params, "clientProperties", Map.class);
    TrustManager trustManager =
        resolveAndRemoveReferenceParameter(params, "trustManager", TrustManager.class);
    RabbitMQEndpoint endpoint;
    if (connectionFactory == null) {
      endpoint = new RabbitMQEndpoint(uri, this);
    } else {
      endpoint = new RabbitMQEndpoint(uri, this, connectionFactory);
    }
    endpoint.setHostname(hostname);
    endpoint.setPortNumber(portNumber);
    endpoint.setExchangeName(exchangeName);
    endpoint.setClientProperties(clientProperties);
    endpoint.setTrustManager(trustManager);
    setProperties(endpoint, params);

    if (LOG.isDebugEnabled()) {
      LOG.debug(
          "Creating RabbitMQEndpoint with host {}:{} and exchangeName: {}",
          new Object[] {
            endpoint.getHostname(), endpoint.getPortNumber(), endpoint.getExchangeName()
          });
    }

    return endpoint;
  }