public Consumer createConsumer(Processor processor) throws Exception { Consumer answer = new NettyConsumer(this, processor, configuration); configureConsumer(answer); return answer; }
public NettyConsumer(NettyEndpoint nettyEndpoint, Processor processor, NettyConfiguration configuration) { super(nettyEndpoint, processor); this.context = this.getEndpoint().getCamelContext(); this.configuration = configuration; setNettyServerBootstrapFactory(configuration.getNettyServerBootstrapFactory()); setExceptionHandler(new NettyConsumerExceptionHandler(this)); }
@Override public ClientInitializerFactory createPipelineFactory(NettyProducer producer) { return new DefaultClientInitializerFactory(producer); } }
@Override protected String createEndpointUri() { ObjectHelper.notNull(configuration, "configuration"); return "netty4:" + getConfiguration().getProtocol() + "://" + getConfiguration().getHost() + ":" + getConfiguration().getPort(); }
public Exchange createExchange(ChannelHandlerContext ctx, Object message) throws Exception { Exchange exchange = createExchange(); updateMessageHeader(exchange.getIn(), ctx); NettyPayloadHelper.setIn(exchange, message); return exchange; }
@Override public void run() { try { LOG.trace("Re-connecting to {} if needed", configuration.getAddress()); doReconnectIfNeeded(); } catch (Exception e) { LOG.warn("Error during re-connect to " + configuration.getAddress() + ". Will attempt again in " + configuration.getReconnectInterval() + " millis. This exception is ignored.", e); } } }, configuration.getReconnectInterval(), TimeUnit.MILLISECONDS);
public NettyConsumerExceptionHandler(NettyConsumer consumer) { this.logger = new CamelLogger(LOG, consumer.getConfiguration().getServerExceptionCaughtLogLevel()); this.closedLoggingLevel = consumer.getConfiguration().getServerClosedChannelExceptionCaughtLogLevel(); }
public NettyProducer(NettyEndpoint nettyEndpoint, NettyConfiguration configuration) { super(nettyEndpoint); this.configuration = configuration; this.context = this.getEndpoint().getCamelContext(); this.noReplyLogger = new CamelLogger(LOG, configuration.getNoReplyLogLevel()); }
@Override protected void doStart() throws Exception { if (configuration == null) { configuration = new NettyConfiguration(); } //Only setup the executorService if it is needed if (configuration.isUsingExecutorService() && executorService == null) { executorService = createExecutorService(); } super.doStart(); }
public Producer createProducer() throws Exception { Producer answer = new NettyProducer(this, configuration); if (isSynchronous()) { return new SynchronousDelegateProducer(answer); } else { return answer; } }
@Override public void operationComplete(ChannelFuture future) throws Exception { notifyChannelOpen(future); } });
@Override protected void doStop() throws Exception { stopServerBootstrap(); }
public NettyWorkerPoolBuilder withName(String name) { setName(name); return this; }
@Override public void handleException(Throwable exception) { handleException(null, null, exception); }
@Override public ServerInitializerFactory createPipelineFactory(NettyConsumer consumer) { return new DefaultServerInitializerFactory(consumer); }
public NettyServerBossPoolBuilder withNativeTransport(boolean nativeTransport) { setNativeTransport(nativeTransport); return this; }
@Override protected void doStop() throws Exception { stopServerBootstrap(); }
public NettyWorkerPoolBuilder withPattern(String pattern) { setPattern(pattern); return this; }
protected EventLoopGroup getWorkerGroup() { // prefer using explicit configured thread pools EventLoopGroup wg = configuration.getWorkerGroup(); if (wg == null) { wg = workerGroup; } return wg; }
public static ChannelHandlerFactory newDelimiterBasedFrameDecoder(final int maxFrameLength, final ByteBuf[] delimiters, String protocol) { return newDelimiterBasedFrameDecoder(maxFrameLength, delimiters, true, protocol); }