Search in sources :

Example 1 with HttpServerMultiplexChannelHandler

use of org.apache.camel.component.netty4.http.handlers.HttpServerMultiplexChannelHandler in project camel by apache.

the class NettyHttpComponent method getMultiplexChannelHandler.

public synchronized HttpServerConsumerChannelFactory getMultiplexChannelHandler(int port) {
    HttpServerConsumerChannelFactory answer = multiplexChannelHandlers.get(port);
    if (answer == null) {
        answer = new HttpServerMultiplexChannelHandler();
        answer.init(port);
        multiplexChannelHandlers.put(port, answer);
    }
    return answer;
}
Also used : HttpServerMultiplexChannelHandler(org.apache.camel.component.netty4.http.handlers.HttpServerMultiplexChannelHandler)

Example 2 with HttpServerMultiplexChannelHandler

use of org.apache.camel.component.netty4.http.handlers.HttpServerMultiplexChannelHandler in project camel by apache.

the class DefaultNettySharedHttpServer method doStart.

protected void doStart() throws Exception {
    ObjectHelper.notNull(configuration, "setNettyServerBootstrapConfiguration() must be called with a NettyServerBootstrapConfiguration instance", this);
    // port must be set
    if (configuration.getPort() <= 0) {
        throw new IllegalArgumentException("Port must be configured on NettySharedHttpServerBootstrapConfiguration " + configuration);
    }
    // hostname must be set
    if (ObjectHelper.isEmpty(configuration.getHost())) {
        throw new IllegalArgumentException("Host must be configured on NettySharedHttpServerBootstrapConfiguration " + configuration);
    }
    LOG.debug("NettySharedHttpServer using configuration: {}", configuration);
    // force using tcp as the underlying transport
    configuration.setProtocol("tcp");
    channelFactory = new HttpServerMultiplexChannelHandler();
    channelFactory.init(configuration.getPort());
    ChannelInitializer<Channel> pipelineFactory = new HttpServerSharedInitializerFactory(configuration, channelFactory, classResolver);
    // thread factory and pattern
    String port = Matcher.quoteReplacement("" + configuration.getPort());
    String pattern = threadPattern;
    pattern = pattern.replaceFirst("#port#", port);
    ThreadFactory tf = new CamelThreadFactory(pattern, "NettySharedHttpServer", true);
    // create bootstrap factory and disable compatible check as its shared among the consumers
    bootstrapFactory = new HttpServerBootstrapFactory(channelFactory, false);
    bootstrapFactory.init(tf, configuration, pipelineFactory);
    ServiceHelper.startServices(channelFactory);
    if (startServer) {
        LOG.info("Starting NettySharedHttpServer on {}:{}", configuration.getHost(), configuration.getPort());
        ServiceHelper.startServices(bootstrapFactory);
    }
}
Also used : CamelThreadFactory(org.apache.camel.util.concurrent.CamelThreadFactory) CamelThreadFactory(org.apache.camel.util.concurrent.CamelThreadFactory) ThreadFactory(java.util.concurrent.ThreadFactory) Channel(io.netty.channel.Channel) HttpServerMultiplexChannelHandler(org.apache.camel.component.netty4.http.handlers.HttpServerMultiplexChannelHandler)

Aggregations

HttpServerMultiplexChannelHandler (org.apache.camel.component.netty4.http.handlers.HttpServerMultiplexChannelHandler)2 Channel (io.netty.channel.Channel)1 ThreadFactory (java.util.concurrent.ThreadFactory)1 CamelThreadFactory (org.apache.camel.util.concurrent.CamelThreadFactory)1