Return-Path: X-Original-To: apmail-camel-commits-archive@www.apache.org Delivered-To: apmail-camel-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A7DD310660 for ; Fri, 14 Mar 2014 10:21:20 +0000 (UTC) Received: (qmail 49261 invoked by uid 500); 14 Mar 2014 10:21:19 -0000 Delivered-To: apmail-camel-commits-archive@camel.apache.org Received: (qmail 48861 invoked by uid 500); 14 Mar 2014 10:21:12 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 47418 invoked by uid 99); 14 Mar 2014 10:20:48 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 14 Mar 2014 10:20:48 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,NORMAL_HTTP_TO_IP X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 14 Mar 2014 10:20:42 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 6294723888E2 for ; Fri, 14 Mar 2014 10:20:22 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r901542 [2/8] - in /websites/production/camel/content: ./ cache/ Date: Fri, 14 Mar 2014 10:20:21 -0000 To: commits@camel.apache.org From: buildbot@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140314102022.6294723888E2@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: websites/production/camel/content/book-component-appendix.html ============================================================================== --- websites/production/camel/content/book-component-appendix.html (original) +++ websites/production/camel/content/book-component-appendix.html Fri Mar 14 10:20:20 2014 @@ -1528,11 +1528,11 @@ template.send("direct:alias-verify&

The cxf: component provides integration with Apache CXF for connecting to JAX-WS services hosted in CXF.

+/*]]>*/

Write to subdirectory using Exchange.FILE_NAME

Using a single route, it is possible to write a file to any number of subdirectories. If you have a route setup as such:

- -

This allows you to have a single route to write files to multiple destinations.

Using expression for filenames

In this sample we want to move consumed files to a backup folder using today's date as a sub-folder name:

+

This allows you to have a single route to write files to multiple destinations.

Writing file through the temporary directory relative to the final destination

Sometime you need to temporarily write the files to some directory relative to the destination directory. Such situation usually happens when some external process with limited filtering capabilities is reading from the directory you are writing to. In the example below files will be written to the  /var/myapp/filesInProgress directory and after data transfer is done, they will be atomically moved to the /var/myapp/finalDirectory directory.

+ +

Using expression for filenames

In this sample we want to move consumed files to a backup folder using today's date as a sub-folder name:

See File Language for more samples.

Avoiding reading the same file more than once (idempotent consumer)

Camel supports Idempotent Consumer directly within the component so it will skip already processed files. This feature can be enabled by setting the idempotent=true option.

@@ -5585,94 +5589,31 @@ fromF("hazelcast:%sfoo", Hazel

Name

Type

Description

CamelHazelcastListenerTime

Long

time of the event in millis Version 2.8

CamelHazelcastListenerType

String

the map consumer sets here "instancelistener" Version 2.8

CamelHazelcastListenerActionn

String

type of event - here added or removed. Version 2.8

CamelHazelcastInstanceHost

String

host name of the instance Version 2.8

CamelHazelcastInstancePort

Integer

port number of the instance Version 2.8

-

HDFS Component

-

Available as of Camel 2.8

- -

The hdfs component enables you to read and write messages from/to an HDFS file system. HDFS is the distributed file system at the heart of Hadoop.

- -

Maven users will need to add the following dependency to their pom.xml for this component:

-
- -
- -

URI format

- -
- -
- -

You can append query options to the URI in the following format, ?option=value&option=value&...
-The path is treated in the following way:

-
  1. as a consumer, if it's a file, it just reads the file, otherwise if it represents a directory it scans all the file under the path satisfying the configured pattern. All the files under that directory must be of the same type.
  2. as a producer, if at least one split strategy is defined, the path is considered a directory and under that directory the producer creates a different file per split named using the configured uuidgenerator.
- - -

Options

-
-

Name

Default Value

Description

overwrite

true

The file can be overwritten

append

false

Append to existing file. Notice that not all HDFS file systems support the append option.

bufferSize

4096

The buffer size used by HDFS

replication

3

The HDFS replication factor

blockSize

67108864

The size of the HDFS blocks

fileType

NORMAL_FILE

It can be SEQUENCE_FILE, MAP_FILE, ARRAY_FILE, or BLOOMMAP_FILE, see Hadoop

fileSystemType

HDFS

It can be LOCAL for local filesystem

keyType

NULL

The type for the key in case of sequence or map files. See below.

valueType

TEXT

The type for the key in case of sequence or map files. See below.

splitStrategy

 

A string describing the strategy on how to split the file based on different criteria. See below.

openedSuffix

opened

When a file is opened for reading/writing the file is renamed with this suffix to avoid to read it during the writing phase.

readSuffix

read

Once the file has been read is renamed with this suffix to avoid to read it again.

initialDelay

0

For the consumer, how much to wait (milliseconds) before to start scanning the directory.

delay

0

The interval (milliseconds) between the directory scans.

pattern

*

The pattern used for scanning the directory

chunkSize

4096

When rea ding a normal file, this is split into chunks producing a message per chunk.

connectOnStartup

true

Camel 2.9.3/2.10.1: Whether to connect to the HDFS file system on starting the producer/consumer. If false then the connection is created on-demand. Notice that HDFS may take up till 15 minutes to establish a connection, as it has hardcoded 45 x 20 sec redelivery. By setting this option to false allows your application to startup, and not block for up till 15 minutes.

-
- -

KeyType and ValueType

-
  • NULL it means that the key or the value is absent
  • BYTE for writing a byte, the java Byte class is mapped into a BYTE
  • BYTES for writing a sequence of bytes. It maps the java ByteBuffer class
  • INT for writing java integer
  • FLOAT for writing java float
  • LONG for writing java long
  • DOUBLE for writing java double
  • TEXT for writing java strings
- - -

BYTES is also used with everything else, for example, in Camel a file is sent around as an InputStream, int this case is written in a sequence file or a map file as a sequence of bytes.

- -

Splitting Strategy

-

In the current version of Hadoop opening a file in append mode is disabled since it's not very reliable. So, for the moment, it's only possible to create new files. The Camel HDFS endpoint tries to solve this problem in this way:

-
  • If the split strategy option has been defined, the hdfs path will be used as a directory and files will be created using the configured uuidgenerator
  • Every time a splitting condition is met, a new file is created.
    -The splitStrategy option is defined as a string with the following syntax:
    -splitStrategy=<ST>:<value>,<ST>:<value>,*
- - -

where <ST> can be:

-
  • BYTES a new file is created, and the old is closed when the number of written bytes is more than <value>
  • MESSAGES a new file is created, and the old is closed when the number of written messages is more than <value>
  • IDLE a new file is created, and the old is closed when no writing happened in the last <value> milliseconds
- - -
+

You can append query options to the URI in the following format, ?option=value&option=value&...
The path is treated in the following way:

  1. as a consumer, if it's a file, it just reads the file, otherwise if it represents a directory it scans all the file under the path satisfying the configured pattern. All the files under that directory must be of the same type.
  2. as a producer, if at least one split strategy is defined, the path is considered a directory and under that directory the producer creates a different file per split named using the configured UuidGenerator.

Options

+

Name

Default Value

Description

overwrite

true

The file can be overwritten

append

false

Append to existing file. Notice that not all HDFS file systems support the append option.

bufferSize

4096

The buffer size used by HDFS

replication

3

The HDFS replication factor

blockSize

67108864

The size of the HDFS blocks

fileType

NORMAL_FILE

It can be SEQUENCE_FILE, MAP_FILE, ARRAY_FILE, or BLOOMMAP_FILE, see Hadoop

fileSystemType

HDFS

It can be LOCAL for local filesystem

keyType

NULL

The type for the key in case of sequence or map files. See below.

valueType

TEXT

The type for the key in case of sequence or map files. See below.

splitStrategy

 

A string describing the strategy on how to split the file based on different criteria. See below.

openedSuffix

opened

When a file is opened for reading/writing the file is renamed with this suffix to avoid to read it during the writing phase.

readSuffix

read

Once the file has been read is renamed with this suffix to avoid to read it again.

initialDelay

0

For the consumer, how much to wait (milliseconds) before to start scanning the directory.

delay

0

The interval (milliseconds) between the directory scans.

pattern

*

The pattern used for scanning the directory

chunkSize

4096

When rea ding a normal file, this is split into chunks producing a message per chunk.

connectOnStartup

true

Camel 2.9.3/2.10.1: Whether to connect to the HDFS file system on starting the producer/consumer. If false then the connection is created on-demand. Notice that HDFS may take up till 15 minutes to establish a connection, as it has hardcoded 45 x 20 sec redelivery. By setting this option to false allows your application to startup, and not block for up till 15 minutes.

owner

 

Camel 2.13/2.12.4: The file owner must match this owner for the consumer to pickup the file. Otherwise the file is skipped.

+

KeyType and ValueType

  • NULL it means that the key or the value is absent
  • BYTE for writing a byte, the java Byte class is mapped into a BYTE
  • BYTES for writing a sequence of bytes. It maps the java ByteBuffer class
  • INT for writing java integer
  • FLOAT for writing java float
  • LONG for writing java long
  • DOUBLE for writing java double
  • TEXT for writing java strings

BYTES is also used with everything else, for example, in Camel a file is sent around as an InputStream, int this case is written in a sequence file or a map file as a sequence of bytes.

Splitting Strategy

In the current version of Hadoop opening a file in append mode is disabled since it's not very reliable. So, for the moment, it's only possible to create new files. The Camel HDFS endpoint tries to solve this problem in this way:

    < li>If the split strategy option has been defined, the hdfs path will be used as a directory and files will be created using the configured UuidGenerator
  • Every time a splitting condition is met, a new file is created.
    The splitStrategy option is defined as a string with the following syntax:
    splitStrategy=<ST>:<value>,<ST>:<value>,*

where <ST> can be:

  • BYTES a new file is created, and the old is closed when the number of written bytes is more than <value>
  • MESSAGES a new file is created, and the old is closed when the number of written messages is more than <value>
  • IDLE a new file is created, and the old is closed when no writing happened in the last <value> milliseconds
Icon
- -

note that this strategy currently requires either setting an IDLE value or setting the HdfsConstants.HDFS_CLOSE header to false to use the BYTES/MESSAGES configuration...otherwise, the file will be closed with each message

+

note that this strategy currently requires either setting an IDLE value or setting the HdfsConstants.HDFS_CLOSE header to false to use the BYTES/MESSAGES configuration...otherwise, the file will be closed with each message

- - -

for example:

-
- -
-

it means: a new file is created either when it has been idle for more than 1 second or if more than 5 bytes have been written. So, running hadoop fs -ls /tmp/simple-file you'll see that multiple files have been created.

- -

Message Headers

- -

The following headers are supported by this component:

- -

Producer only

-
+

it means: a new file is created either when it has been idle for more than 1 second or if more than 5 bytes have been written. So, running hadoop fs -ls /tmp/simple-file you'll see that multiple files have been created.

Message Headers

The following headers are supported by this component:

Producer only

Header

Description

CamelFileName

Camel 2.13: Specifies the name of the file to write (relative to the endpoint path). The name can be a String or an Expression object. Only relevant when not using a split strategy.

-
- -

Controlling to close file stream

-

Available as of Camel 2.10.4

- -

When using the HDFS producer without a split strategy, then the file output stream is by default closed after the write. However you may want to keep the stream open, and only explicitly close the stream later. For that you can use the header HdfsConstants.HDFS_CLOSE (value = "CamelHdfsClose") to control this. Setting this value to a boolean allows you to explicit control whether the stream should be closed or not.

- -

Notice this does not apply if you use a split strategy, as there are various strategies that can control when the stream is closed.

- - -

Using this component in OSGi

-

This component is fully functional in an OSGi environment, however, it requires some actions from the user. Hadoop uses the thread context class loader in order to load resources. Usually, the thread context classloader will be the bundle class loader of the bundle that contains the routes. So, the default configuration files need to be visible from the bundle class loader. A typical way to deal with it is to keep a copy of core-default.xml in your bundle root. That file can be found in the hadoop-common.jar.

+

Controlling to close file stream

Available as of Camel 2.10.4

When using the HDFS producer without a split strategy, then the file output stream is by default closed after the write. However you may want to keep the stream open, and only explicitly close the stream later. For that you can use the header HdfsConstants.HDFS_CLOSE (value = "CamelHdfsClose") to control this. Setting this value to a boolean allows you to explicit control whether the stream should be closed or not.

Notice this does not apply if you use a split strategy, as there are various strategies that can control when the stream is closed.

Using this component in OSGi

This component is fully functional in an OSGi environment, however, it requires some actions from the user. Hadoop uses the thread context class loader in order to load resources. Usually, the thread context classloader will be the bundle class loader of the bundle that contains the routes. So, the default configuration files need to be visible from the bundle class loader. A typical way to deal with it is to keep a copy of core-default.xml in your bundle root. That file can be found in the hadoop-common.jar.

Hibernate Component

The hibernate: component allows you to work with databases using Hibernate as the object relational mapping technology to map POJOs to database tables. The camel-hibernate library is provided by the Camel Extra project which hosts all *GPL related components for Camel.

@@ -7378,118 +7319,50 @@ from("timer://foo?period=60000"

See Also

-

Jetty Component

- -

The jetty component provides HTTP-based endpoints for consuming and producing HTTP requests. That is, the Jetty component behaves as a simple Web server.
-Jetty can also be used as a http client which mean you can also use it with Camel as a producer.

- -
+

Jetty Component

The jetty component provides HTTP-based endpoints for consuming and producing HTTP requests. That is, the Jetty component behaves as a simple Web server.
Jetty can also be used as a http client which mean you can also use it with Camel as a producer.

Stream

Icon
- -

Jetty is stream based, which means the input it receives is submitted to Camel as a stream. That means you will only be able to read the content of the stream once.
-If you find a situation where the message body appears to be empty or you need to access the data multiple times (eg: doing multicasting, or redelivery error handling)
-you should use Stream Caching or convert the message body to a String which is safe to be re-read multiple times.

+

Jetty is stream based, which means the input it receives is submitted to Camel as a stream. That means you will only be able to read the content of the stream once.
If you find a situation where the message body appears to be empty or you need to access the data multiple times (eg: doing multicasting, or redelivery error handling)
you should use Stream caching or convert the message body to a String which is safe to be re-read multiple times.

- - -

Maven users will need to add the following dependency to their pom.xml for this component:

-
- -
- -

URI format

- -
- -
- -

You can append query options to the URI in the following format, ?option=value&option=value&...

- -

Options

-
+

You can append query options to the URI in the following format, ?option=value&option=value&...

Options

Name

Default Value

Description

sessionSupport

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 httpClien t.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 H ttpClient 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 Jettys 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 254 threads used in Jettys 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). Important: You can not use different handlers with different Jetty endpoint s 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

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.

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.

throwExceptionOnFailure

true

Option to disable throwing the HttpOperationFailedException in case of failed responses from the remote server. This allows you to get all responses regardles 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 true , HttpProducer 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". Also consider setting disableStreamCache to true to optimize when bridging.

enableMultipartFilter

true

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

multipartFilterRef

null

Camel 2.6: Allows using a custom multipart filter. Note: setting multipartFilterRef forces the value of enableMultipartFilter to true.

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 millis when using Jetty as consumer (server). By default Je tty 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 a 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: 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.

traceEnabled

false

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

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.

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 UrlR ewrite 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.

-
- -

Message Headers

- -

Camel uses the same message headers as the HTTP component.
-From Camel 2.2, it also uses (Exchange.HTTP_CHUNKED,CamelHttpChunked) header to turn on or turn off the chuched 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.

- -

Starting with Camel 2.2.0, you can get the request.parameter from the message header not only from Get Method, but also other HTTP method.

- -

Usage

- -

The Jetty component supports both consumer and producer endpoints. Another option for producing to other HTTP endpoints, is to use the HTTP Component

- -

Component Options

- -

The JettyHttpComponent provides the following options:

-
+Camel 2.3: If the option is true, HttpProducer and CamelServlet will skip the gzip processing if the content-encoding is "gzip". Also consider setting disableStreamCache to true to optimize when bridging.

enableMultipartFilter

true

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

multipartFilterRef

null

Camel 2.6: Allows using a custom multipart filter. Note: setting multipartFilterRef forces the value of enableMultipartFilter to true.

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 millis when using Jetty as consumer (server). By default Je tty 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 a 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: 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.

traceEnabled

false

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

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.

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 UrlR ewrite 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.

+

Message Headers

Camel uses the same message headers as the HTTP component.
From Camel 2.2, it also uses (Exchange.HTTP_CHUNKED,CamelHttpChunked) header to turn on or turn off the chuched 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.

Starting with Camel 2.2.0, you can get the request.parameter from the message header not only from Get Method, but also other HTTP method.

Usage

The Jetty component supports both consumer and producer endpoints. Another option for producing to other HTTP endpoints, is to use the HTTP Component

Component Options

The JettyHttpComponent provides the following options:

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 keyst ore 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.

httpClient

null

Deprecated: Producer only: To use a custom HttpClient with the jetty producer. This option is removed from Camel 2.11 onwards, instead you can set the option on the endpoint instead.

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.

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 configur ed.

httpClientThreadPool

null

Deprecated: Producer only: To use a custom thread pool for the client. This option is removed from Camel 2.11 onwards.

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.

requestBuff erSize

null

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

requestHeaderSize

null

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

responseBufferSize

null

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

responseHeaderSize

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 a http proxy.

proxyPort

null

Camel 2.12.2/2.11.3: To use a http proxy.

-
- -

Producer Example

- -

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

- -

in Java DSL

- -
- -
- -

or in Spring XML

- -
- -
- -

Consumer Example

- -

In this sample we define a route that exposes a HTTP service at http://localhost:8080/myapp/myservice:

-
+

Consumer Example

In this sample we define a route that exposes a HTTP service at http://localhost:8080/myapp/myservice:

-
- -
+

Usage of localhost

Icon
- -

When you specify localhost in a URL, Camel exposes the endpoint only on the local TCP/IP network interface, so it cannot be accessed from outside the machine it operates on.

- -

If you need to expose a Jetty endpoint on a specific network interface, the numerical IP address of this interface should be used as the host. If you need to expose a Jetty endpoint on all network interfaces, the 0.0.0.0 address should be used.

+

When you specify localhost in a URL, Camel exposes the endpoint only on the local TCP/IP network interface, so it cannot be accessed from outside the machine it operates on.

If you need to expose a Jetty endpoint on a specific network interface, the numerical IP address of this interface should be used as the host. If you need to expose a Jetty endpoint on all network interfaces, the 0.0.0.0 address should be used.

- - -

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.

-
+

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.

-
- -

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.

-
+

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.

-
-

So if a client sends the 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 El or OGNL--we could also test for the parameter value and do routing based on the header value as well.

- -

Session Support

- -

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:

- -
- -
- -

The myCode Processor can be instantiated by a Spring bean element:

- -
- -
- -

Where the processor implementation can access the HttpSession as follows:

- -
- -
- -

SSL Support (HTTPS)

- - -
Using the JSSE Configuration Utility
- -

As of Camel 2.8, the Jetty component supports SSL/TLS configuration through the Camel JSSE Configuration Utility.  This utility greatly decreases the amount of component specific code you need to write and is configurable at the endpoint and component levels.  The following examples demonstrate how to use the utility with the Jetty component.

- -
Programmatic configuration of the component
-
- -
- -
Spring DSL based configuration of endpoint
-
- -
- -
Configuring Jetty Directly
- -

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

- -
- -
- -

Jetty also needs to know where to load your keystore from and what passwords to use in order to load the correct SSL certificate. Set the following JVM System Properties:

- -

until Camel 2.2

-
  • jetty.ssl.keystore specifies the location of the Java keystore file, which contains the Jetty server's own X.509 certificate in a key entry. A key entry stores the X.509 certificate (effectively, the public key) and also its associated private key.
  • jetty.ssl.password the store password, which is required to access the keystore file (this is the same password that is supplied to the keystore command's -storepass option).
  • jetty.ssl.keypassword the key password, which is used to access the certificate's key entry in the keystore (this is the same password that is supplied to the keystore command's -keypass option).
- - -

from Camel 2.3 onwards

-
  • org.eclipse.jetty.ssl.keystore specifies the location of the Java keystore file, which contains the Jetty server's own X.509 certificate in a key entry. A key entry stores the X.509 certificate (effectively, the public key) and also its associated private key.
  • org.eclipse.jetty.ssl.password the store password, which is required to access the keystore file (this is the same password that is supplied to the keystore command's -storepass option).
  • org.eclipse.jetty.ssl.keypassword the key password, which is used to access the certificate's key entry in the keystore (this is the same password that is supplied to the keystore command's -keypass option).
- - -

For details of how to configure SSL on a Jetty endpoint, read the following documentation at the Jetty Site: http://docs.codehaus.org/display/JETTY/How+to+configure+SSL

- - - - -

Some SSL properties aren't exposed directly by Camel, however Camel does expose the underlying SslSocketConnector, which will allow you to set properties like needClientAuth for mutual authentication requiring a client certificate or wantClientAuth for mutual authentication where a client doesn't need a certificate but can have one. There's a slight difference between the various Camel versions:

- -

Up to Camel 2.2

-
-