Class NettyConfiguration

All Implemented Interfaces:
Cloneable

@UriParams @Configurer public class NettyConfiguration extends NettyServerBootstrapConfiguration implements Cloneable
  • Constructor Details

    • NettyConfiguration

      public NettyConfiguration()
  • Method Details

    • copy

      public NettyConfiguration copy()
      Returns a copy of this configuration
    • validateConfiguration

      public void validateConfiguration()
    • parseURI

      public void parseURI(URI uri, Map<String,Object> parameters, NettyComponent component, String... supportedProtocols) throws Exception
      Throws:
      Exception
    • getCharsetName

      public String getCharsetName()
    • getRequestTimeout

      public long getRequestTimeout()
    • setRequestTimeout

      public void setRequestTimeout(long requestTimeout)
      Allows to use a timeout for the Netty producer when calling a remote server. By default no timeout is in use. The value is in milli seconds, so eg 30000 is 30 seconds. The requestTimeout is using Netty's ReadTimeoutHandler to trigger the timeout.
    • isSync

      public boolean isSync()
    • setSync

      public void setSync(boolean sync)
      Setting to set endpoint as one-way or request-response
    • isTextline

      public boolean isTextline()
    • setTextline

      public void setTextline(boolean textline)
      Only used for TCP. If no codec is specified, you can use this flag to indicate a text line based codec; if not specified or the value is false, then Object Serialization is assumed over TCP - however only Strings are allowed to be serialized by default.
    • getDecoderMaxLineLength

      public int getDecoderMaxLineLength()
    • setDecoderMaxLineLength

      public void setDecoderMaxLineLength(int decoderMaxLineLength)
      The max line length to use for the textline codec.
    • getDelimiter

      public TextLineDelimiter getDelimiter()
    • setDelimiter

      public void setDelimiter(TextLineDelimiter delimiter)
      The delimiter to use for the textline codec. Possible values are LINE and NULL.
    • isAutoAppendDelimiter

      public boolean isAutoAppendDelimiter()
    • setAutoAppendDelimiter

      public void setAutoAppendDelimiter(boolean autoAppendDelimiter)
      Whether or not to auto append missing end delimiter when sending using the textline codec.
    • getEncoding

      public String getEncoding()
    • setEncoding

      public void setEncoding(String encoding)
      The encoding (a charset name) to use for the textline codec. If not provided, Camel will use the JVM default Charset.
    • getDecodersAsList

      public List<io.netty.channel.ChannelHandler> getDecodersAsList()
    • setDecodersAsList

      public void setDecodersAsList(List<io.netty.channel.ChannelHandler> decoders)
    • setDecoders

      public void setDecoders(List<io.netty.channel.ChannelHandler> decoders)
      A list of decoders to be used. You can use a String which have values separated by comma, and have the values be looked up in the Registry. Just remember to prefix the value with # so Camel knows it should lookup.
    • setDecoders

      public void setDecoders(String decoders)
      A list of decoders to be used. You can use a String which have values separated by comma, and have the values be looked up in the Registry. Just remember to prefix the value with # so Camel knows it should lookup.
    • getDecoders

      public String getDecoders()
    • getEncodersAsList

      public List<io.netty.channel.ChannelHandler> getEncodersAsList()
    • setEncodersAsList

      public void setEncodersAsList(List<io.netty.channel.ChannelHandler> encoders)
    • setEncoders

      public void setEncoders(List<io.netty.channel.ChannelHandler> encoders)
      A list of encoders to be used. You can use a String which have values separated by comma, and have the values be looked up in the Registry. Just remember to prefix the value with # so Camel knows it should lookup.
    • setEncoders

      public void setEncoders(String encoders)
      A list of encoders to be used. You can use a String which have values separated by comma, and have the values be looked up in the Registry. Just remember to prefix the value with # so Camel knows it should lookup.
    • getEncoders

      public String getEncoders()
    • addEncoder

      public void addEncoder(io.netty.channel.ChannelHandler encoder)
      Adds a custom ChannelHandler class that can be used to perform special marshalling of outbound payloads.
    • addDecoder

      public void addDecoder(io.netty.channel.ChannelHandler decoder)
      Adds a custom ChannelHandler class that can be used to perform special marshalling of inbound payloads.
    • isDisconnect

      public boolean isDisconnect()
    • setDisconnect

      public void setDisconnect(boolean disconnect)
      Whether or not to disconnect(close) from Netty Channel right after use. Can be used for both consumer and producer.
    • isLazyChannelCreation

      public boolean isLazyChannelCreation()
    • setLazyChannelCreation

      public void setLazyChannelCreation(boolean lazyChannelCreation)
      Channels can be lazily created to avoid exceptions, if the remote server is not up and running when the Camel producer is started.
    • isTransferExchange

      public boolean isTransferExchange()
    • setTransferExchange

      public void setTransferExchange(boolean transferExchange)
      Only used for TCP. You can transfer the exchange over the wire instead of just the body. The following fields are transferred: In body, Out body, fault body, In headers, Out headers, fault headers, exchange properties, exchange exception. This requires that the objects are serializable. Camel will exclude any non-serializable objects and log it at WARN level.
    • isAllowSerializedHeaders

      public boolean isAllowSerializedHeaders()
    • setAllowSerializedHeaders

      public void setAllowSerializedHeaders(boolean allowSerializedHeaders)
      Only used for TCP when transferExchange is true. When set to true, serializable objects in headers and properties will be added to the exchange. Otherwise Camel will exclude any non-serializable objects and log it at WARN level.
    • isDisconnectOnNoReply

      public boolean isDisconnectOnNoReply()
    • setDisconnectOnNoReply

      public void setDisconnectOnNoReply(boolean disconnectOnNoReply)
      If sync is enabled then this option dictates NettyConsumer if it should disconnect where there is no reply to send back.
    • getNoReplyLogLevel

      public org.apache.camel.LoggingLevel getNoReplyLogLevel()
    • setNoReplyLogLevel

      public void setNoReplyLogLevel(org.apache.camel.LoggingLevel noReplyLogLevel)
      If sync is enabled this option dictates NettyConsumer which logging level to use when logging a there is no reply to send back.
    • getServerExceptionCaughtLogLevel

      public org.apache.camel.LoggingLevel getServerExceptionCaughtLogLevel()
    • setServerExceptionCaughtLogLevel

      public void setServerExceptionCaughtLogLevel(org.apache.camel.LoggingLevel serverExceptionCaughtLogLevel)
      If the server (NettyConsumer) catches an exception then its logged using this logging level.
    • getServerClosedChannelExceptionCaughtLogLevel

      public org.apache.camel.LoggingLevel getServerClosedChannelExceptionCaughtLogLevel()
    • setServerClosedChannelExceptionCaughtLogLevel

      public void setServerClosedChannelExceptionCaughtLogLevel(org.apache.camel.LoggingLevel serverClosedChannelExceptionCaughtLogLevel)
      If the server (NettyConsumer) catches an java.nio.channels.ClosedChannelException then its logged using this logging level. This is used to avoid logging the closed channel exceptions, as clients can disconnect abruptly and then cause a flood of closed exceptions in the Netty server.
    • isAllowDefaultCodec

      public boolean isAllowDefaultCodec()
    • setAllowDefaultCodec

      public void setAllowDefaultCodec(boolean allowDefaultCodec)
      The netty component installs a default codec if both, encoder/decoder is null and textline is false. Setting allowDefaultCodec to false prevents the netty component from installing a default codec as the first element in the filter chain.
    • setClientPipelineFactory

      @Deprecated public void setClientPipelineFactory(ClientInitializerFactory clientPipelineFactory)
      Deprecated.
      use #setClientInitializerFactory
    • getClientPipelineFactory

      @Deprecated public ClientInitializerFactory getClientPipelineFactory()
      Deprecated.
      use #getClientInitializerFactory
    • getClientInitializerFactory

      public ClientInitializerFactory getClientInitializerFactory()
    • setClientInitializerFactory

      public void setClientInitializerFactory(ClientInitializerFactory clientInitializerFactory)
      To use a custom ClientInitializerFactory
    • isUsingExecutorService

      public boolean isUsingExecutorService()
    • setUsingExecutorService

      public void setUsingExecutorService(boolean usingExecutorService)
      Whether to use ordered thread pool, to ensure events are processed orderly on the same channel.
    • getProducerPoolMaxTotal

      public int getProducerPoolMaxTotal()
    • setProducerPoolMaxTotal

      public void setProducerPoolMaxTotal(int producerPoolMaxTotal)
      Sets the cap on the number of objects that can be allocated by the pool (checked out to clients, or idle awaiting checkout) at a given time. Use a negative value for no limit.
    • getProducerPoolMinIdle

      public int getProducerPoolMinIdle()
    • setProducerPoolMinIdle

      public void setProducerPoolMinIdle(int producerPoolMinIdle)
      Sets the minimum number of instances allowed in the producer pool before the evictor thread (if active) spawns new objects.
    • getProducerPoolMaxIdle

      public int getProducerPoolMaxIdle()
    • setProducerPoolMaxIdle

      public void setProducerPoolMaxIdle(int producerPoolMaxIdle)
      Sets the cap on the number of "idle" instances in the pool.
    • getProducerPoolMinEvictableIdle

      public long getProducerPoolMinEvictableIdle()
    • setProducerPoolMinEvictableIdle

      public void setProducerPoolMinEvictableIdle(long producerPoolMinEvictableIdle)
      Sets the minimum amount of time (value in millis) an object may sit idle in the pool before it is eligible for eviction by the idle object evictor.
    • getProducerPoolMaxWait

      public long getProducerPoolMaxWait()
    • setProducerPoolMaxWait

      public void setProducerPoolMaxWait(long producerPoolMaxWait)
      Sets the maximum duration (value in millis) the borrowObject() method should block before throwing an exception when the pool is exhausted and producerPoolBlockWhenExhausted is true. When less than 0, the borrowObject() method may block indefinitely.
    • isProducerPoolBlockWhenExhausted

      public boolean isProducerPoolBlockWhenExhausted()
    • setProducerPoolBlockWhenExhausted

      public void setProducerPoolBlockWhenExhausted(boolean producerPoolBlockWhenExhausted)
      Sets the value for the blockWhenExhausted configuration attribute. It determines whether to block when the borrowObject() method is invoked when the pool is exhausted (the maximum number of "active" objects has been reached).
    • isProducerPoolEnabled

      public boolean isProducerPoolEnabled()
    • setProducerPoolEnabled

      public void setProducerPoolEnabled(boolean producerPoolEnabled)
      Whether producer pool is enabled or not.

      Important: If you turn this off then a single shared connection is used for the producer, also if you are doing request/reply. That means there is a potential issue with interleaved responses if replies comes back out-of-order. Therefore you need to have a correlation id in both the request and reply messages so you can properly correlate the replies to the Camel callback that is responsible for continue processing the message in Camel. To do this you need to implement NettyCamelStateCorrelationManager as correlation manager and configure it via the correlationManager option.

      See also the correlationManager option for more details.

    • isUdpConnectionlessSending

      public boolean isUdpConnectionlessSending()
    • setUdpConnectionlessSending

      public void setUdpConnectionlessSending(boolean udpConnectionlessSending)
      This option supports connection less udp sending which is a real fire and forget. A connected udp send receive the PortUnreachableException if no one is listen on the receiving port.
    • isClientMode

      public boolean isClientMode()
    • setClientMode

      public void setClientMode(boolean clientMode)
      If the clientMode is true, netty consumer will connect the address as a TCP client.
    • isUseByteBuf

      public boolean isUseByteBuf()
    • setUseByteBuf

      public void setUseByteBuf(boolean useByteBuf)
      If the useByteBuf is true, netty producer will turn the message body into ByteBuf before sending it out.
    • isUdpByteArrayCodec

      public boolean isUdpByteArrayCodec()
    • setUdpByteArrayCodec

      public void setUdpByteArrayCodec(boolean udpByteArrayCodec)
      For UDP only. If enabled the using byte array codec instead of Java serialization protocol.
    • isReuseChannel

      public boolean isReuseChannel()
    • setReuseChannel

      public void setReuseChannel(boolean reuseChannel)
      This option allows producers and consumers (in client mode) to reuse the same Netty Channel for the lifecycle of processing the Exchange. This is useful if you need to call a server multiple times in a Camel route and want to use the same network connection. When using this, the channel is not returned to the connection pool until the Exchange is done; or disconnected if the disconnect option is set to true.

      The reused Channel is stored on the Exchange as an exchange property with the key NettyConstants.NETTY_CHANNEL which allows you to obtain the channel during routing and use it as well.

    • getCorrelationManager

      public NettyCamelStateCorrelationManager getCorrelationManager()
    • setCorrelationManager

      public void setCorrelationManager(NettyCamelStateCorrelationManager correlationManager)
      To use a custom correlation manager to manage how request and reply messages are mapped when using request/reply with the netty producer. This should only be used if you have a way to map requests together with replies such as if there is correlation ids in both the request and reply messages. This can be used if you want to multiplex concurrent messages on the same channel (aka connection) in netty. When doing this you must have a way to correlate the request and reply messages so you can store the right reply on the inflight Camel Exchange before its continued routed.

      We recommend extending the TimeoutCorrelationManagerSupport when you build custom correlation managers. This provides support for timeout and other complexities you otherwise would need to implement as well.

      See also the producerPoolEnabled option for more details.

    • isHostnameVerification

      public boolean isHostnameVerification()
    • setHostnameVerification

      public void setHostnameVerification(boolean hostnameVerification)
      To enable/disable hostname verification on SSLEngine