Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Div
classconfluenceTableSmall
Camel 2.16: Producer only The status codes which is considered a success response. The values are inclusive. The range must be defined as from-to with the dash included

Name

Default Value

Description

sessionSupportbridgeEndpoint

false

Specifies whether to enable the session manager on the server side of Jetty.

httpClient.xxx

null

Configuration of Jetty's HttpClient. For example, setting httpClient.idleTimeout=30000 sets the idle timeout to 30 seconds. And httpClient.timeout=30000 sets the request timeout to 30 seconds, in case you want to timeout sooner if you have long running request/response calls.

httpClient

null

To use a shared org.eclipse.jetty.client.HttpClient for all producers created by this endpoint. This option should only be used in special circumstances.

httpClientMinThreads

null

Camel 2.11: Producer only: To set a value for minimum number of threads in HttpClient thread pool. This setting override any setting configured on component level. Notice that both a min and max size must be configured. If not set it default to min 8 threads used in Jetty's thread pool.

Camel 2.1: If the option is trueHttpProducer will ignore the Exchange.HTTP_URI header, and use the endpoint's URI for request. You may also set the throwExceptionOnFailure to be false to let the HttpProducer send all the fault response back.

Camel 2.3: If the option is true, HttpProducer and CamelServlet will skip the gzip processing if the Content-Encoding is gzip.

Consider setting disableStreamCache=true to optimize when bridging.

chunked

true

Camel 2.2: If this option is false Jetty Servlet will disable the HTTP streaming and set the Content-Length header on the response

continuationTimeouthttpClientMaxThreads

null

Camel 2.11: Producer only: To set a value for maximum number of threads in HttpClient thread pool. This setting override any setting configured on component level. Notice that both a min and max size must be configured. If not set it default to max 16 threads used in Jetty's thread pool.

httpBindingRef

null

Reference to an org.apache.camel.component.http.HttpBinding in the Registry. HttpBinding can be used to customize how a response should be written for the consumer.

jettyHttpBindingRef

null

Camel 2.6.0+: Reference to an org.apache.camel.component.jetty.JettyHttpBinding in the Registry. JettyHttpBinding can be used to customize how a response should be written for the producer.

matchOnUriPrefix

false

Whether or not the CamelServlet should try to find a target consumer by matching the URI prefix if no exact match is found.

See here How do I let Jetty match wildcards.

handlers

null

Specifies a comma-delimited set of org.mortbay.jetty.Handler instances in your Registry (such as your Spring ApplicationContext). These handlers are added to the Jetty servlet context (for example, to add security). Note: you can not use different handlers with different Jetty endpoints using the same port number. The handlers is associated to the port number. If you need different handlers, then use different port numbers.

chunked

true

Camel 2.2: If this option is false Jetty servlet will disable the HTTP streaming and set the Content-Length header on the response

6: Allows to set a timeout in milliseconds when using Jetty as consumer (server). By default Jetty uses 30000. You can use a value of <= 0 to never expire. If a timeout occurs then the request will be expired and Jetty will return back an HTTP error 503 to the client.

This option is only in use when using Jetty with the Asynchronous Routing Engine.

disableStreamCache

false

Camel 2.3: Determines whether or not the raw input stream from Jetty is cached or not (Camel will read the stream into a in memory/overflow to file, Stream caching) cache. By default Camel will cache the Jetty input stream to support reading it multiple times to ensure it Camel can retrieve all data from the stream. However you can set this option to true when you for example need to access the raw stream, such as streaming it directly to a file or other persistent store. 

DefaultHttpBinding will copy the request input stream into a stream cache and put it into message body if this option is false to support reading the stream multiple times. If you use Jetty to bridge/proxy an endpoint then consider enabling this option to improve performance, in case you do not need to read the message payload multiple times.

enableCORS

false

Camel 2.15: if the option is true, Jetty server will setup the CrossOriginFilter which supports the CORS out of box.

enableJmx

false

Camel 2.3: If this option is true, Jetty JMX support will be enabled for this

enableJmx

false

Camel 2.3: If this option is true, Jetty JMX support will be enabled for this endpoint. See Jetty JMX support for more details.

disableStreamCacheenablemulti-partFilter

falsetrue

Camel 2.3: Determines whether or not the raw input stream from Jetty is cached or not (Camel will read the stream into a in memory/overflow to file, Stream caching) cache. By default Camel will cache the Jetty input stream to support reading it multiple times to ensure it Camel can retrieve all data from the stream. However you can set this option to true when you for example need to access the raw stream, such as streaming it directly to a file or other persistent store. 

DefaultHttpBinding will copy the request input stream into a stream cache and put it into message body if this option is false to support reading the stream multiple times. If you use Jetty to bridge/proxy an endpoint then consider enabling this option to improve performance, in case you do not need to read the message payload multiple times.

throwExceptionOnFailure

true

Option to disable throwing the HttpOperationFailedException in case of failed responses from the remote server. This allows you to get all responses regardless of the HTTP status code.

transferException

false

Camel 2.6: If enabled and an Exchange failed processing on the consumer side, and if the caused Exception was send back serialized in the response as a application/x-java-serialized-object content type.

On the producer side the exception will be deserialized and thrown as is, instead of the HttpOperationFailedException. The caused exception is required to be serialized.

bridgeEndpoint

false

Camel 2.1: If the option is trueHttpProducer will ignore the Exchange.HTTP_URI header, and use the endpoint's URI for request. You may also set the throwExceptionOnFailure to be false to let the HttpProducer send all the fault response back.

Camel 2.3: If the option is true, HttpProducer and CamelServlet will skip the gzip processing if the Content-Encoding is gzip.

Consider setting disableStreamCache=true to optimize when bridging.

enablemulti-partFilter

true

Camel 2.5: Whether Jetty org.eclipse.jetty.servlets.multi-partFilter is enabled or not. You should set this value to false when bridging endpoints, to ensure multi-part requests is proxied/bridged as well.

multi-partFilterRef

null

Camel 2.6: Allows using a custom multi-part filter. Note: setting multi-partFilterRef forces the value of enablemulti-partFilter to true.

filterInit.xxx

null

Camel 2.17: Configuration for the InitParameters of filter. For example, setting filterInit.parameter=value the parameter could be used when calling the filter init() method.

filtersRef

null

Camel 2.9: Allows using a custom filters which is putted into a list and can be find in the Registry

continuationTimeout

null

Camel 2.6: Allows to set a timeout in milliseconds when using Jetty as consumer (server). By default Jetty uses 30000. You can use a value of <= 0 to never expire. If a timeout occurs then the request will be expired and Jetty will return back an HTTP error 503 to the client.

This option is only in use when using Jetty with the Asynchronous Routing Engine.

useContinuation

true

Camel 2.6: Whether or not to use Jetty continuations for the Jetty Server.

sslContextParametersRef

null

Camel 2.8: Deprecated Reference to a org.apache.camel.util.jsse.SSLContextParameters in the Registry.  This reference overrides any configured SSLContextParameters at the component level. 

See Using the JSSE Configuration Utility.

sslContextParameters

null

Camel 2.17: Reference to a org.apache.camel.util.jsse.SSLContextParameters in the Registry.  This reference overrides any configured SSLContextParameters at the component level.   

See Using the JSSE Configuration Utility.

5: Whether Jetty org.eclipse.jetty.servlets.multi-partFilter is enabled or not.

Set this option to false when bridging endpoints, to ensure multi-part requests is proxied/bridged as well.

filterInit.xxx

null

Camel 2.17: Configuration for the InitParameters of filter.

For example, setting filterInit.parameter=value the parameter could be used when calling the filter init() method.

filtersRef

null

Camel 2.9: Allows using a custom filters which is putted into a list and can be find in the Registry

handlers

null

Specifies a comma-delimited set of org.mortbay.jetty.Handler instances in your Registry (such as your Spring ApplicationContext). These handlers are added to the Jetty servlet context (for example, to add security). Note: you can not use different handlers with different Jetty endpoints using the same port number. The handlers is associated to the port number. If you need different handlers, then use different port numbers.

headerFilterStrategy

null

Camel 2.11: Reference to a instance of org.apache.camel.spi.HeaderFilterStrategy in the Registry. It will be used to apply the custom headerFilterStrategy on the new create HttpJettyEndpoint.

httpBindingRef

null

Reference to an org.apache.camel.component.http.HttpBinding in the Registry. HttpBinding can be used to customize how a response should be written for the consumer.

httpClient.xxx

null

Configuration of Jetty's HttpClient. For example, setting httpClient.idleTimeout=30000 sets the idle timeout to 30 seconds. And httpClient.timeout=30000 sets the request timeout to 30 seconds, in case you want to timeout sooner if you have long running request/response calls.

httpClient

null

To use a shared org.eclipse.jetty.client.HttpClient for all producers created by this endpoint. This option should only be used in special circumstances.

httpClientMinThreads

null

Camel 2.11: Producer only: To set a value for minimum number of threads in HttpClient thread pool. This setting override any setting configured on component level. Notice that both a min and max size must be configured. If not set it default to min 8 threads used in Jetty's thread pool.

httpClientMaxThreads

null

Camel 2.11: Producer only: To set a value for maximum number of threads in HttpClient thread pool. This setting override any setting configured on component level. Notice that both a min and max size must be configured. If not set it default to max 16 threads used in Jetty's thread pool.

httpMethodRestrict

null

Camel 2.11: Consumer only: Used to only allow consuming if the HttpMethod matches, such as GET/POST/PUT etc. From Camel 2.15: multiple methods can be specified separated by comma.

jettyHttpBindingRef

null

Camel 2.6.0+: Reference to an org.apache.camel.component.jetty.JettyHttpBinding in the Registry. JettyHttpBinding can be used to customize how a response should be written for the producer.

matchOnUriPrefix

false

Whether or not the CamelServlet should try to find a target consumer by matching the URI prefix if no exact match is found.

See here How do I let Jetty match wildcards.

multi-partFilterRef

null

Camel 2.6: Allows using a custom multi-part filter. Note: setting multi-partFilterRef forces the value of enablemulti-partFilter to true.

okStatusCodeRange

200-299

Camel 2.16: Producer only The status codes which is considered a success response. The values are inclusive. The range must be defined as from-to with the dash included.

traceEnabled

false

Specifies whether to enable HTTP TRACE for this Jetty consumer. By default TRACE is turned off.

optionsEnabled

false

Camel 2.17: Specifies whether to enable HTTP OPTIONS for this Jetty consumer. By default OPTIONS is turned off.

headerFilterStrategyproxyHost

null

Camel 2.11: Reference to a instance of org.apache.camel.spi.HeaderFilterStrategy in the Registry. It will be used to apply the custom headerFilterStrategy on the new create HttpJettyEndpoint.

httpMethodRestrict

null

Camel 2.11: Consumer only: Used to only allow consuming if the HttpMethod matches, such as GET/POST/PUT etc. From Camel 2.15: multiple methods can be specified separated by comma.

urlRewrite

null

Camel 2.11: Producer only Refers to a custom org.apache.camel.component.http.UrlRewrite which allows you to rewrite URLs when you bridge/proxy endpoints.

See more details at UrlRewrite and How to use Camel as a HTTP proxy between a client and server.

responseBufferSize

null

Camel 2.12: To use a custom buffer size on the javax.servlet.ServletResponse.

proxyHost

null

Camel 2.11: Producer only The HTTP proxy Host URL which will be used by Jetty client.

proxyPort

null

Camel 2.11: Producer only The HTTP proxy port which will be used by Jetty client.

sendServerVersion

true

Camel 2.13: if the option is true, jetty will send the server header with the jetty version information to the client which sends the request.

Note: please make sure there is no any other camel-jetty endpoint is share the same port, otherwise this option may not work as expected.

sendDateHeader

false

Camel 2.14: if the option is true, jetty server will send the date header to the client which sends the request. Note: please make sure there is no any other camel-jetty endpoint is share the same port, otherwise this option may not work as expected.

enableCORS

false

Camel 2.15: if the option is true, Jetty server will setup the CrossOriginFilter which supports the CORS out of box.

Producer only The HTTP proxy Host URL which will be used by Jetty client.

proxyPort

null

Camel 2.11: Producer only The HTTP proxy port which will be used by Jetty client.

responseBufferSize

null

Camel 2.12: To use a custom buffer size on the javax.servlet.ServletResponse.

sendDateHeader

false

Camel 2.14: if the option is true, jetty server will send the date header to the client which sends the request. Note: please make sure there is no any other camel-jetty endpoint is share the same port, otherwise this option may not work as expected.

sendServerVersion

true

Camel 2.13: if the option is true, jetty will send the server header with the jetty version information to the client which sends the request.

Note: please make sure there is no any other camel-jetty endpoint is share the same port, otherwise this option may not work as expected.

sessionSupport

false

Specifies whether to enable the session manager on the server side of Jetty.

sslContextParameters

null

Camel 2.17: Reference to a org.apache.camel.util.jsse.SSLContextParameters in the Registry.  This reference overrides any configured SSLContextParameters at the component level.   

See Using the JSSE Configuration Utility.

sslContextParametersRef

null

Camel 2.8: Deprecated Reference to a org.apache.camel.util.jsse.SSLContextParameters in the Registry.  This reference overrides any configured SSLContextParameters at the component level. 

See Using the JSSE Configuration Utility.

throwExceptionOnFailure

true

Option to disable throwing the HttpOperationFailedException in case of failed responses from the remote server. This allows you to get all responses regardless of the HTTP status code.

traceEnabled

false

Specifies whether to enable HTTP TRACE for this Jetty consumer. By default TRACE is turned off.

transferException

false

Camel 2.6: If enabled and an Exchange failed processing on the consumer side, and if the caused Exception was send back serialized in the response as a application/x-java-serialized-object content type.

On the producer side the exception will be deserialized and thrown as is, instead of the HttpOperationFailedException. The caused exception is required to be serialized.

urlRewrite

null

Camel 2.11: Producer only Refers to a custom org.apache.camel.component.http.UrlRewrite which allows you to rewrite URLs when you bridge/proxy endpoints.

See more details at UrlRewrite and How to use Camel as a HTTP proxy between a client and server.

useContinuation

true

Camel 2.6: Whether or not to use Jetty continuations for the Jetty Server

okStatusCodeRange

200-299

.

Message Headers

Camel uses the same message headers as the HTTP component. From Camel 2.2, it also uses (Exchange.HTTP_CHUNKEDCamelHttpChunked) header to toggle chunked encoding on the camel-jetty consumer. Camel also populates all request.parameter and request.headers. For example, given a client request with the URL, http://myserver/myserver?orderid=123, the exchange will contain a header named orderid with the value 123.

...

Div
classconfluenceTableSmall
errorHandler15: This option is used to set the ErrorHandler that Jetty server uses.false161/.15.5 Whether to allow java serialization when a request uses context-type=application/x-java-serialized-object.When true, be aware that Java will deserialize the incoming data from the request to Java and that can be a potential security risk

Name

Default Value

Description

enableJmx

false

Camel 2.3: If this option is true, Jetty JMX support will be enabled for this endpoint. See Jetty JMX support for more details.

sslKeyPassword

null

Consumer only: The password for the keystore when using SSL.

sslPassword

null

Consumer only: The password when using SSL.

sslKeystore

null

Consumer only: The path to the keystore.

minThreads

null

Camel 2.5 Consumer only: To set a value for minimum number of threads in server thread pool. Notice that both a min and max size must be configured.

maxThreads

null

Camel 2.5 Consumer only: To set a value for maximum number of threads in server thread pool. Notice that both a min and max size must be configured.

threadPool

null

Camel 2.5 Consumer only: To use a custom thread pool for the server. This option should only be used in special circumstances.

sslSocketConnectors

null

Camel 2.3 Consumer only: A map which contains per port number specific SSL connectors. See section SSL support for more details.

socketConnectors

null

Camel 2.5 Consumer only: A map which contains per port number specific HTTP connectors. Uses the same principle as sslSocketConnectors and therefore see section SSL support for more details.

sslSocketConnectorProperties

null

Camel 2.5 Consumer only. A map which contains general SSL connector properties. See section SSL support for more details.

socketConnectorProperties

null

Camel 2.5 Consumer only. A map which contains general HTTP connector properties. Uses the same principle as sslSocketConnectorProperties and therefore see section SSL support for more details.

Value

Description

allowJavaSerializedObject

false

Camel 2.16.1/2.15.5: Whether to allow java serialization when a request uses context-type=application/x-java-serialized-object.

When true, be aware that Java will deserialize the incoming data from the request to Java and that can be a potential security risk.

enableJmx

false

Camel 2.3: If this option is true, Jetty JMX support will be enabled for this endpoint. See Jetty JMX support for more details.

errorHandler

null

Camel 2.15: This option is used to set the ErrorHandler that Jetty server uses.

httpClient

null

Deprecated: Producer only: To use a custom HttpClient with the jetty producer.

Note: from Camel 2.11 this option has been removed. Set the option on the endpoint instead.

httpClientMaxThreads

null

Producer only: To set a value for maximum number of threads in HttpClient thread pool. Notice that both a min and max size must be configured.

httpClientMinThreads

null

Producer only: To set a value for minimum number of threads in HttpClient thread pool. Notice that both a min and max size must be configured.

httpClientThreadPoolhttpClient

null

Deprecated: Producer only: To use a custom HttpClient with the jetty producerthread pool for the client.

Note: from Camel 2.11 this option has been removed . Set the option on the endpoint insteadfrom Camel 2.11.

httpClientMinThreadsmaxThreads

null

Producer Camel 2.5 Consumer only: To set a value for minimum maximum number of threads in HttpClient server thread pool. Notice that both a min and max size must be configured.

httpClientMaxThreadsminThreads

null

Producer Camel 2.5 Consumer only: To set a value for maximum minimum number of threads in HttpClient server thread pool. Notice that both a min and max size must be configured.max size must be configured.

proxyHost

null

Camel 2.12.2/2.11.3 To use an HTTP proxy.

proxyPort

null

Camel 2.12.2/2.11.3: To use an HTTP proxy.

socketConnectors

null

Camel 2.5 Consumer only: A map which contains per port number specific HTTP connectors. Uses the same principle as sslSocketConnectors and therefore see section SSL support for more details.

socketConnectorProperties

null

Camel 2.5 Consumer only. A map which contains general HTTP connector properties. Uses the same principle as sslSocketConnectorProperties and therefore see section SSL support for more details

httpClientThreadPool

null

Deprecated: Producer only: To use a custom thread pool for the client.

Note: this option has been removed from Camel 2.11.

sslContextParameters

null

Camel 2.8: To configure a custom SSL/TLS configuration options at the component level. 

See  Using the JSSE Configuration Utility for more details..

sslKeyPassword

null

Consumer only: The password for the keystore when using SSL.

sslKeystore

null

Consumer only: The path to the keystore.

sslPassword

null

Consumer only: The password when using SSL.

sslSocketConnectorsrequestBufferSize

null

Camel 2.11.2: Allows to configure a custom value of the request buffer size on the Jetty connectors.3 Consumer only: A map which contains per port number specific SSL connectors. See section SSL support for more details.

sslSocketConnectorPropertiesrequestHeaderSize

null

Camel 2.11.2: Allows to configure a custom value of the request header size on the Jetty connectors..5 Consumer only. A map which contains general SSL connector properties. See section SSL support for more details.

requestBufferSizeresponseBufferSize

null

Camel 2.11.2: Allows to configure a custom value of the response request buffer size on the Jetty connectors.

responseHeaderSizerequestHeaderSize

null

Camel 2.11.2: Allows to configure a custom value of the response header size on the Jetty connectors.

proxyHost

null

Camel 2.12.2/2.11.3 To use an HTTP proxy.

proxyPort

null

Camel 2.12.2/2.11.3: To use an HTTP proxy.

request header size on the Jetty connectors.

responseBufferSize

null

Camel 2.

allowJavaSerializedObject

11.2: Allows to configure a custom value of the response buffer size on the Jetty connectors.

responseHeaderSize

null

Camel 2.

11.

2

:

Allows to configure a custom value of the response header size on the Jetty connectors.

threadPool

null

Camel 2.5 Consumer only: To use a custom thread pool for the server. This option should only be used in special circumstances

.

Producer Example

The following is a basic example of how to send an HTTP request to an existing HTTP endpoint.

Java DSL:

Code Block
java
java
from("direct:start")
  .to("jetty://http://www.google.com");

XML DSL:

Code Block
xml
xml
<route>
    <from uri="direct:start"/>
    <to uri="jetty://http://www.google.com"/>
<route>

...

Our business logic is implemented in the MyBookService class, which accesses the HTTP request contents and then returns a response.
Note: The assert call appears in this example, because the code is part of an unit test.

Wiki Markup
{snippet:id=e2|lang=java|url=camel/trunk/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/JettyRouteTest.java}
The following sample shows a content-based route that routes all requests containing the URI parameter, one, to the endpoint, mock:one, and all others to mock:other.
Wiki Markup
{snippet:id=e1|lang=java|url=camel/trunk/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/JettyContentBasedRouteTest.java}
So if If a client sends the an HTTP request, http://serverUri?one=hello, the Jetty component will copy the HTTP request parameter, one to the exchange's in.header. We can then use the simple language to route exchanges that contain this header to a specific endpoint and all others to another. If we used a language more powerful than Simple (such as , e.g., EL or OGNL) we could , then we can also test for the parameter value and do routing route based on the header value as well.

...

The session support option, sessionSupport, can be used to enable a HttpSession object and access the session object while processing the exchange.

For example, the following route enables sessions:

...

Jetty provides SSL support out of the box. To enable Jetty to run in SSL mode, simply format the URI using the https:// prefix.

Example:

Code Block
xml
xml
<from uri="jetty:https://0.0.0.0/myapp/myservice/"/>

...

Code Block
xml
xml
<bean id="jetty" class="org.apache.camel.component.jetty.JettyHttpComponent">
    <property name="socketConnectorProperties">
        <map>
            <entry key="acceptors" value="4"/>
            <entry key="maxIdleTime" value="300000"/>
        </map>
    </property>
</bean>

...

How to Get the Value of The X-Forwarded-For HTTP Header

...

Using HttpServletRequest.getRemoteAddr()

If the HTTP requests are handled by an Apache server and forwarded to jetty Jetty with mod_proxy, the original client IP address is in the X-Forwarded-For header and the HttpServletRequest.getRemoteAddr() will return the address of the Apache proxy.

...

The default behavior of HTTP status codes is defined by the org.apache.camel.component.http.DefaultHttpBinding class, which handles how a response is written and also sets the HTTP status code. If the exchange was processed successfully, the 200 HTTP status code is returned. If the exchange failed with an exception, the 500 HTTP status code is returned, and the stacktrace is returned in the body. If you want to specify which HTTP status code to return, set the code in the Exchange.HTTP_RESPONSE_CODE header of the OUT message.

...

If you need more handlers, set the handlers option equal to a comma-separated list of bean IDs.

...

From Camel 2.3.0camel-jetty supports the enabling of Jetty's JMX capabilities at the component and endpoint level with the endpoint configuration taking priority. Note that JMX must be enabled within the Camel context in order to enable JMX support in this component as the component provides Jetty with a reference to the MBeanServer registered with the Camel context. Because

As the camel-jetty component caches and reuses Jetty resources for a given protocol/host/port pairing, this configuration option will only be evaluated during the creation of the first endpoint to use a protocol/host/port pairing. For example,

Example: given two routes created from the following XML fragments, JMX support would remain enabled for all endpoints listening on: https://0.0.0.0.

...