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;
}
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);
}
}
Aggregations