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 DEDC5174C7 for ; Tue, 22 Sep 2015 14:32:01 +0000 (UTC) Received: (qmail 78054 invoked by uid 500); 22 Sep 2015 14:32:01 -0000 Delivered-To: apmail-camel-commits-archive@camel.apache.org Received: (qmail 78008 invoked by uid 500); 22 Sep 2015 14:32:01 -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 77999 invoked by uid 99); 22 Sep 2015 14:32:01 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 Sep 2015 14:32:01 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 2D536180973 for ; Tue, 22 Sep 2015 14:32:01 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 4.301 X-Spam-Level: **** X-Spam-Status: No, score=4.301 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RDNS_NONE=2.5, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id 8wK_lfoLSu-T for ; Tue, 22 Sep 2015 14:31:48 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (unknown [209.188.14.139]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with ESMTP id 664B044161 for ; Tue, 22 Sep 2015 14:31:48 +0000 (UTC) Received: from svn01-us-west.apache.org (svn.apache.org [10.41.0.6]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id EE278E043F for ; Tue, 22 Sep 2015 14:26:47 +0000 (UTC) Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id DCFDC3A01A5 for ; Tue, 22 Sep 2015 14:26:47 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r966362 [9/21] - /websites/production/camel/content/ Date: Tue, 22 Sep 2015 14:26:37 -0000 To: commits@camel.apache.org From: buildbot@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20150922142647.DCFDC3A01A5@svn01-us-west.apache.org> Modified: websites/production/camel/content/controlbus.html ============================================================================== --- websites/production/camel/content/controlbus.html (original) +++ websites/production/camel/content/controlbus.html Tue Sep 22 14:26:24 2015 @@ -98,29 +98,29 @@ or use the event notifier which has an e

From Camel 2.11 onwards we have introduced a new ControlBus Component that allows you to send messages to a control bus Endpoint that reacts accordingly.

ControlBus Component

Available as of Camel 2.11

The controlbus: component provides easy management of Camel applications based on the Control Bus EIP pattern.
For example, by sending a message to an Endpoint you can control the lifecycle of routes, or gather performance statistics.

-
controlbus:command[?options]
-
+

Where command can be any string to identify which type of command to use.

Commands

Command

Description

route

To control routes using the routeId and action parameter.

language

Allows you to specify a Language to use for evaluating the message body. If there is any result from the evaluation, then the result is put in the message body.

Options

Name

Default Value

Description

routeId

null

To specify a route by its id.

action

null

To denote an action that can be either: start, stop, suspend, resume, or status. To either start or stop a route, or to get the status of the route as output in the message body. You can use suspend and resume from Camel 2.11.1 onwards to either suspend or resume a route. And from Camel 2.11.1 onwards you can use stats to get performance statics returned in XML format; the routeId option can be used to define which route to get the performance stats for, if routeId is not defined, then you get statistics for the entire CamelContext.

async

false

Whether to execute the control bus task asynchronously. Important: If this option is enabled, then any result from the task is not set on the Exchange. This is only possible if executing tasks synchronously.

loggingLevel

INFO

Logging level used for logging when task is done, or if any exceptions occurred during processing the task.

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

Samples

Using route command

The route command allows you to do common tasks on a given route very easily, for example to start a route, you can send an empty message to this endpoint:

-
template.sendBody("controlbus:route?routeId=foo&action=start", null);
-
+

To get the status of the route, you can do:

-
String status = template.requestBody("controlbus:route?routeId=foo&action=status", null, String.class);
-
+
Getting performance statistics

Available as of Camel 2.11.1

This requires JMX to be enabled (is by default) then you can get the performance statics per route, or for the CamelContext. For example to get the statics for a route named foo, we can do:

-
String xml = template.requestBody("controlbus:route?routeId=foo&action=stats", null, String.class);
-
+

The returned statics is in XML format. Its the same data you can get from JMX with the dumpRouteStatsAsXml operation on the ManagedRouteMBean.

To get statics for the entire CamelContext you just omit the routeId parameter as shown below:

-
String xml = template.requestBody("controlbus:route?action=stats", null, String.class);
-
+

Using Simple language

You can use the Simple language with the control bus, for example to stop a specific route, you can send a message to the "controlbus:language:simple" endpoint containing the following message:

-
template.sendBody("controlbus:language:simple", "${camelContext.stopRoute('myRoute')}");
-
+

As this is a void operation, no result is returned. However, if you want the route status you can do:

-
String status = template.requestBody("controlbus:language:simple", "${camelContext.getRouteStatus('myRoute')}", String.class);
-
+

Notice: its easier to use the route command to control lifecycle of routes. The language command allows you to execute a language script that has stronger powers such as Groovy or to some extend the Simple language.

For example to shutdown Camel itself you can do:

-
template.sendBody("controlbus:language:simple?async=true", "${camelContext.stop()}");
-
+

Notice we use async=true to stop Camel asynchronously as otherwise we would be trying to stop Camel while it was in-flight processing the message we sent to the control bus component.

You can also use other languages such as Groovy, etc.

See Also

@@ -132,7 +132,7 @@ or use the event notifier which has an e Modified: websites/production/camel/content/couchdb.html ============================================================================== --- websites/production/camel/content/couchdb.html (original) +++ websites/production/camel/content/couchdb.html Tue Sep 22 14:26:24 2015 @@ -97,22 +97,22 @@

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

-
+
 

URI format

-
+
 

Where hostname is the hostname of the running couchdb instance. Port is optional and if not specified then defaults to 5984.

@@ -140,32 +140,32 @@ couchdb:http://hostname[:port]/database?

For example if you wish to consume all inserts, updates and deletes from a CouchDB instance running locally, on port 9999 then you could use the following:

-
-from("couchdb:http://localhost:9999").process(someProcessor);
-
+

If you were only interested in deletes, then you could use the following

-
-from("couchdb:http://localhost:9999?updates=false").process(someProcessor);
-
+

If you wanted to insert a message as a document, then the body of the exchange is used

-
-from("someProducingEndpoint").process(someProcessor).to("couchdb:http://localhost:9999")
-
+
Modified: websites/production/camel/content/cxf-async-example.html ============================================================================== --- websites/production/camel/content/cxf-async-example.html (original) +++ websites/production/camel/content/cxf-async-example.html Tue Sep 22 14:26:24 2015 @@ -100,18 +100,18 @@

You will need to compile this example first:

-
+
 

The example should run if you type:

-
+
 

To stop the server hit ctrl + c

@@ -121,18 +121,18 @@

As the client is single threaded it will send the messages in order, e.g. from 0 to 99.

-
+
 

As the HTTP server is simulating some time to process each message its replies will likely come after all the client have send all 100 messages. When they arrive they come back out of order

-
+
 

And as you can see they are being handled by different threads, as we have configured using a poolSize=10 option.

@@ -154,7 +154,7 @@

The output is then as expected a request, reply and so forth. And of course the throughput is much lower as we are only handle a single message at the time and blocked while waiting for the webserver reply.

-
+
 
@@ -173,7 +173,7 @@ Modified: websites/production/camel/content/cxf-example-osgi-blueprint.html ============================================================================== --- websites/production/camel/content/cxf-example-osgi-blueprint.html (original) +++ websites/production/camel/content/cxf-example-osgi-blueprint.html Tue Sep 22 14:26:24 2015 @@ -86,38 +86,38 @@

CXF Example OSGi Blueprint

Available as of Camel 2.8

Spring-DM vs. OSGi Blueprint

This example uses OSGi Blueprint for OSGi. There is another CXF Example OSGi that uses Spring-DM.

A simple example which receives web service calls (via a CXF consumer, using bean binding)
and writes these requests into the file system. It's not a very useful use case, but the goal
of this example is to show you how you can use the CXF consumer component in an OSGI
environment with the OSGI HTTP service. If your target co ntainer is Apache Karaf or Apache
ServiceMix, you can use PAX Web to setup and start an OSGI HTTP service. All Camel
bundles using a Camel CXF consumer can use this HTTP service without needing to start
individual Jetty instances. Another advantage is that all provided services can now share
the same port.

This example is located in the examples/camel-example-cxf-blueprint directory of the Camel distribution.
There is a README.txt file with instructions how to run it.

You will need to compile this example first:

-
  mvn install
-
+

To run the example on Apache ServiceMix 4.x or Apache Karaf 2.x

1) launch the server

-
  karaf.bat
-  
+

Note for Karaf 2.2.x:
a) edit the etc/jre.properties file to add the following packages to be exported

-
      jre-1.6=, \
+
 

b) from the same file comment out the following exports already provided by the bundles
that will be imported next: javax.xml.bind*, javax.jws*, javax.xml.soap*, javax.xml.ws*,
javax.activation, javax.annotation, javax.xml.stream*.

2) Add features required

-
 
+
 

Note: Apache Camel 2.9.0 is being used above, but you should of course change the
version number to the exact version of Camel being used.

3) Deploy the example bundle

-
  osgi:install -s mvn:org.apache.camel/camel-example-cxf-blueprint
-  
+

4) Verify that your service is available using the following url in the browser.
We assume you're using Karaf's default PAX Web configuration which uses
port 8181 for http. If you would like to use another port or https, change the configuration in
${KARAF_HOME}/etc/org.ops4j.pax.web.cfg. The immediate extension after the hostname and port ("cxf" in
the below URL) is configured via the org.apache.cxf.osgi.cfg file (Please see
http://team.ops4j.org/wiki//display/paxweb/Pax+Web for more information on PAX Web).

-
  http://localhost:8181/cxf/camel-example-cxf-blueprint/webservices/incident?wsdl
-  
+

5) Start SOAPUI or use curl to send the request
Create a new project called camel-example-cxf-osgi
Point to the following url: http://localhost:8181/cxf/camel-example-cxf-blueprint/webservices/incident?wsdl
Open the request 1 (under camel-example-cxf-blueprint --> ReportIncidentBinding --> ReportIncident) and copy/paste a SOAP
message generated by the unit test, for example:

ex :
--> and the message formatted that you copy in SOAPUI

-
   
-   <xml version="1.0" encoding="UTF-8"?>
-   <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
+
 

If you use curl, you need to save the upper message in a file (data.xml) first and use the blow command to send the message. 

-
curl -X POST -T data.xml -H "Content-Type: text/xml" http://localhost:8181/cxf/camel-example-cxf-osgi/webservices/incident
+

The response message looks like this

-
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
+
 

 

6) Check the file system
Check the folder "target/inbox/" in the Karaf base directory to see that a message has arrived.

See Also

Modified: websites/production/camel/content/cxfrs.html ============================================================================== --- websites/production/camel/content/cxfrs.html (original) +++ websites/production/camel/content/cxfrs.html Tue Sep 22 14:26:24 2015 @@ -126,29 +126,35 @@ </jaxrs:serviceBeans> </jaxrs:server> - <!-- bean id="jsonProvider" class="org.apache.cxf.jaxrs.provider.JSONProvider"/--> + <bean id="jsonProvider" class="org.apache.cxf.jaxrs.provider.json.JSONProvider"/> <bean id="customerService" class="org.apache.camel.component.cxf.jaxrs.testbean.CustomerService" /> <!-- Defined the server endpoint to create the cxf-rs consumer --> <cxf:rsServer id="rsServer" address="http://localhost:${CXFTestSupport.port1}/CxfRsRouterTest/route" serviceClass="org.apache.camel.component.cxf.jaxrs.testbean.CustomerService" - loggingFeatureEnabled="true" loggingSizeLimit="20" skipFaultLogging="true"/> + loggingFeatureEnabled="true" loggingSizeLimit="20" skipFaultLogging="true"> + <cxf:providers> + <ref bean="jsonProvider"/> + </cxf:providers> + </cxf:rsServer> <!-- Defined the client endpoint to create the cxf-rs consumer --> <cxf:rsClient id="rsClient" address="http://localhost:${CXFTestSupport.port2}/CxfRsRouterTest/rest" serviceClass="org.apache.camel.component.cxf.jaxrs.testbean.CustomerService" - loggingFeatureEnabled="true" skipFaultLogging="true"/> + loggingFeatureEnabled="true" skipFaultLogging="true"> + <cxf:providers> + <ref bean="jsonProvider"/> + </cxf:providers> + </cxf:rsClient> <!-- The camel route context --> <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"> <route> + <!-- Just need to ignoreDeleteMethodMessageBody --> <from uri="cxfrs://bean://rsServer"/> - <!-- We can remove this configure as the CXFRS producer is using the HttpAPI by default --> - <setHeader headerName="CamelCxfRsUsingHttpAPI"> - <constant>True</constant> - </setHeader> - <to uri="cxfrs://bean://rsClient"/> + <to uri="log:body?level=INFO"/> + <to uri="cxfrs://bean://rsClient?ignoreDeleteMethodMessageBody=true"/> </route> </camelContext> @@ -190,69 +196,33 @@ Payload: ]]>

For more examples on how to process requests and write responses can be found here.

Consuming a REST Request - Default Binding Style

The CXF JAXRS front end implements the JAX-RS (JSR-311) API, so we can export the resources classes as a REST service. And we leverage the CXF Invoker API to turn a REST request into a normal Java object method invocation.
Unlike the Camel Restlet 60;component, you don't need to specify the URI template within your endpoint, CXF takes care of the REST request URI to resource class method mapping according to the JSR-311 specification. All you need to do in Camel is delegate this method request to a right processor or endpoint.

Here is an example of a CXFRS route...

How to invoke the REST service through camel-cxfrs producer

The CXF JAXRS front end implements a proxy-based client API, with this API you can invoke the remote REST service through a proxy. The camel-cxfrs producer is based on this proxy API.
You just need to specify the operation name in the message header and prepare the parameter in the message body, the camel-cxfrs producer will generate right REST request for you.

Here is an example:

@@ -284,6 +263,8 @@ Exchange exchange = template.send(" inMessage.setHeader(CxfConstants.CAMEL_CXF_RS_USING_HTTP_API, Boolean.FALSE); // set a customer header inMessage.setHeader("key", "value"); + // setup the accept content type + inMessage.setHeader(Exchange.ACCEPT_CONTENT_TYPE, "application/json"); // set the parameters , if you just have one parameter // camel will put this object into an Object[] itself inMessage.setBody("123"); Modified: websites/production/camel/content/documentation.html ============================================================================== --- websites/production/camel/content/documentation.html (original) +++ websites/production/camel/content/documentation.html Tue Sep 22 14:26:24 2015 @@ -90,7 +90,7 @@