Exemple #1
0
  @Override
  protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters)
      throws Exception {
    NettyConfiguration config;
    if (configuration != null) {
      config = configuration.copy();
    } else {
      config = new NettyConfiguration();
    }
    config = parseConfiguration(config, remaining, parameters);

    // merge any custom bootstrap configuration on the config
    NettyServerBootstrapConfiguration bootstrapConfiguration =
        resolveAndRemoveReferenceParameter(
            parameters, "bootstrapConfiguration", NettyServerBootstrapConfiguration.class);
    if (bootstrapConfiguration != null) {
      Map<String, Object> options = new HashMap<String, Object>();
      if (IntrospectionSupport.getProperties(bootstrapConfiguration, options, null, false)) {
        IntrospectionSupport.setProperties(getCamelContext().getTypeConverter(), config, options);
      }
    }

    // validate config
    config.validateConfiguration();

    NettyEndpoint nettyEndpoint = new NettyEndpoint(remaining, this, config);
    nettyEndpoint.setTimer(getTimer());
    setProperties(nettyEndpoint.getConfiguration(), parameters);
    return nettyEndpoint;
  }
  @Override
  protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters)
      throws Exception {
    NettyConfiguration config;
    if (configuration != null) {
      config = configuration.copy();
    } else {
      config = new NettyConfiguration();
    }

    config.parseURI(new URI(remaining), parameters, this);

    NettyEndpoint nettyEndpoint = new NettyEndpoint(remaining, this, config);
    nettyEndpoint.setTimer(getTimer());
    setProperties(nettyEndpoint.getConfiguration(), parameters);
    return nettyEndpoint;
  }
Exemple #3
0
  protected OrderedMemoryAwareThreadPoolExecutor createExecutorService() {
    // use ordered thread pool, to ensure we process the events in order, and can send back
    // replies in the expected order. eg this is required by TCP.
    // and use a Camel thread factory so we have consistent thread namings
    // we should use a shared thread pool as recommended by Netty

    // NOTE: if we don't specify the MaxChannelMemorySize and MaxTotalMemorySize, the thread pool
    // could eat up all the heap memory when the tasks are added very fast

    String pattern = getCamelContext().getExecutorServiceManager().getThreadNamePattern();
    ThreadFactory factory = new CamelThreadFactory(pattern, "NettyOrderedWorker", true);
    return new OrderedMemoryAwareThreadPoolExecutor(
        getMaximumPoolSize(),
        configuration.getMaxChannelMemorySize(),
        configuration.getMaxTotalMemorySize(),
        30,
        TimeUnit.SECONDS,
        factory);
  }
Exemple #4
0
  @Override
  protected void doStart() throws Exception {
    if (timer == null) {
      HashedWheelTimer hashedWheelTimer = new HashedWheelTimer();
      hashedWheelTimer.start();
      timer = hashedWheelTimer;
    }

    if (configuration == null) {
      configuration = new NettyConfiguration();
    }
    if (configuration.isOrderedThreadPoolExecutor()) {
      executorService = createExecutorService();
    }

    super.doStart();
  }
Exemple #5
0
 /**
  * Parses the configuration
  *
  * @return the parsed and valid configuration to use
  */
 protected NettyConfiguration parseConfiguration(
     NettyConfiguration configuration, String remaining, Map<String, Object> parameters)
     throws Exception {
   configuration.parseURI(new URI(remaining), parameters, this, "tcp", "udp");
   return configuration;
 }