Modified: websites/production/camel/content/using-camelproxy.html
==============================================================================
--- websites/production/camel/content/using-camelproxy.html (original)
+++ websites/production/camel/content/using-camelproxy.html Fri Aug 25 08:22:01 
2017
@@ -36,17 +36,6 @@
     <![endif]-->
 
 
-  <link href='//camel.apache.org/styles/highlighter/styles/shCoreCamel.css' 
rel='stylesheet' type='text/css' />
-  <link href='//camel.apache.org/styles/highlighter/styles/shThemeCamel.css' 
rel='stylesheet' type='text/css' />
-  <script src='//camel.apache.org/styles/highlighter/scripts/shCore.js' 
type='text/javascript'></script>
-  <script src='//camel.apache.org/styles/highlighter/scripts/shBrushJava.js' 
type='text/javascript'></script>
-  <script src='//camel.apache.org/styles/highlighter/scripts/shBrushXml.js' 
type='text/javascript'></script>
-  <script src='//camel.apache.org/styles/highlighter/scripts/shBrushPlain.js' 
type='text/javascript'></script>
-  
-  <script type="text/javascript">
-  SyntaxHighlighter.defaults['toolbar'] = false;
-  SyntaxHighlighter.all();
-  </script>
 
     <title>
     Apache Camel: Using CamelProxy
@@ -86,146 +75,18 @@
        <tbody>
         <tr>
         <td valign="top" width="100%">
-<div class="wiki-content maincontent"><h2 
id="UsingCamelProxy-UsingCamelProxy">Using CamelProxy</h2><p>Camel allows you 
to proxy a producer sending to an <a shape="rect" 
href="endpoint.html">Endpoint</a> by a regular interface. Then when clients 
using this interface can work with it as if its regular java code but in 
reality its proxied and does a <a shape="rect" 
href="request-reply.html">Request Reply</a> to a given endpoint.</p><h3 
id="UsingCamelProxy-ProxyfromSpring">Proxy from Spring</h3><p>You can define a 
proxy in the spring XML file as shown below</p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
-&lt;camelContext xmlns=&quot;http://camel.apache.org/schema/spring&quot;&gt;
-
-    &lt;!-- create a proxy that will route to the direct:start endpoint when 
invoked --&gt;
-    &lt;proxy id=&quot;myProxySender&quot;
-           
serviceInterface=&quot;org.apache.camel.spring.config.MyProxySender&quot;
-           serviceUrl=&quot;direct:start&quot;/&gt;
-
-    &lt;!-- this is the route that our proxy will routed when invoked
-         and the output from this route is returned as reply on the proxy 
--&gt; 
-    &lt;route&gt;
-        &lt;from uri=&quot;direct:start&quot;/&gt;
-        &lt;transform&gt;
-            &lt;simple&gt;Bye ${body}&lt;/simple&gt;
-        &lt;/transform&gt;
-    &lt;/route&gt;
-
-&lt;/camelContext&gt;
-]]></script>
-</div></div>Now the client can grab this bean using regular spring bean coding 
and invoke it as if its just another bean.<br clear="none"> The code is based 
on an unit test but proves the point:<div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
-AbstractApplicationContext ac = new 
ClassPathXmlApplicationContext(&quot;org/apache/camel/spring/config/AnotherCamelProxyTest.xml&quot;);
-
-MyProxySender sender = ac.getBean(&quot;myProxySender&quot;, 
MyProxySender.class);
-String reply = sender.hello(&quot;Camel&quot;);
-
-assertEquals(&quot;Bye Camel&quot;, reply);
-
-// we&#39;re done so let&#39;s properly close the application context
-IOHelper.close(ac);
-]]></script>
-</div></div><h3 id="UsingCamelProxy-ProxyfromJava">Proxy from Java</h3><p>You 
can also create a proxy from regular Java using a 
<code>org.apache.camel.component.bean.ProxyHelper</code> as shown 
below:</p><div class="code panel pdl" style="border-width: 1px;"><div 
class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[    Endpoint endpoint = 
context.getEndpoint(&quot;direct:start&quot;);
+<div class="wiki-content maincontent"><h2 
id="UsingCamelProxy-UsingCamelProxy">Using CamelProxy</h2><p>Camel allows you 
to proxy a producer sending to an <a shape="rect" 
href="endpoint.html">Endpoint</a> by a regular interface. Then when clients 
using this interface can work with it as if its regular java code but in 
reality its proxied and does a <a shape="rect" 
href="request-reply.html">Request Reply</a> to a given endpoint.</p><h3 
id="UsingCamelProxy-ProxyfromSpring">Proxy from Spring</h3><p>You can define a 
proxy in the spring XML file as shown 
below<plain-text-body>{snippet:id=e1|lang=xml|url=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/AnotherCamelProxyTest.xml}</plain-text-body>Now
 the client can grab this bean using regular spring bean coding and invoke it 
as if its just another bean.<br clear="none"> The code is based on an unit test 
but proves the 
point:<plain-text-body>{snippet:id=e1|lang=java|url=camel/trunk/components/camel-sprin
 
g/src/test/java/org/apache/camel/spring/config/AnotherCamelProxyTest.java}</plain-text-body></p><h3
 id="UsingCamelProxy-ProxyfromJava">Proxy from Java</h3><p>You can also create 
a proxy from regular Java using a 
<code>org.apache.camel.component.bean.ProxyHelper</code> as shown 
below:</p><plain-text-body>    Endpoint endpoint = 
context.getEndpoint("direct:start");
     MyProxySender sender = ProxyHelper.createProxy(endpoint, 
MyProxySender.class);
-]]></script>
-</div></div><p>In <strong>Camel 2.3</strong> you can use 
<code>org.apache.camel.builder.ProxyBuilder</code> which may be easier to use 
than ProxyHelper:</p><div class="code panel pdl" style="border-width: 
1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
-public void testProxyBuilderProxyCallAnotherBean() throws Exception {
-    // use ProxyBuilder to easily create the proxy
-    OrderService service = new 
ProxyBuilder(context).endpoint(&quot;direct:bean&quot;).build(OrderService.class);
-
-    String reply = service.submitOrderStringReturnString(&quot;World&quot;);
-    assertEquals(&quot;Hello World&quot;, reply);
-}
-]]></script>
-</div></div><h3 id="UsingCamelProxy-ProxywithAnnotation">Proxy with 
Annotation</h3><p>Another way to configure the proxy from java is by using the 
@Produce annotation. Also see <a shape="rect" href="pojo-producing.html">POJO 
Producing</a>.</p><div class="code panel pdl" style="border-width: 1px;"><div 
class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[@Produce(uri=&quot;direct:start&quot;)
+</plain-text-body><p>In <strong>Camel 2.3</strong> you can use 
<code>org.apache.camel.builder.ProxyBuilder</code> which may be easier to use 
than 
ProxyHelper:<plain-text-body>{snippet:id=e4|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/BeanProxyTest.java}</plain-text-body></p><h3
 id="UsingCamelProxy-ProxywithAnnotation">Proxy with Annotation</h3><p>Another 
way to configure the proxy from java is by using the @Produce annotation. Also 
see <a shape="rect" href="pojo-producing.html">POJO 
Producing</a>.</p><plain-text-body>@Produce(uri="direct:start")
 MyProxySender sender;
-]]></script>
-</div></div><p>This basically does the same as ProxyHelper.createProxy.</p><h3 
id="UsingCamelProxy-WhatissendontheMessage">What is send on the 
Message</h3><p>When using a proxy Camel will send the message payload as a 
<code>org.apache.camel.component.bean.BeanInvocation</code> object (*Camel 2.15 
or older) which holds the details of which method was invoked and what the 
argument was.&#160;From&#160;<strong style="line-height: 1.4285715;">Camel 
2.16</strong> onwards Camel parameter binding is enabled by default, which will 
use binding information from the method signature parameters to bind to the 
Exchange/Message with the following annotations</p><div 
class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" 
rowspan="1" class="confluenceTh">Annotation</th><th colspan="1" rowspan="1" 
class="confluenceTh">Parameter Type</th><th colspan="1" rowspan="1" 
class="confluenceTh">Parameter binds to</th></tr><tr><td colspan="1" 
rowspan="1" class="confluenceTd">@Body</td><td 
 colspan="1" rowspan="1" class="confluenceTd">Object</td><td colspan="1" 
rowspan="1" class="confluenceTd">Binds the parameter to the message 
body</td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd">@Header(name)</td><td colspan="1" rowspan="1" 
class="confluenceTd">Object</td><td colspan="1" rowspan="1" 
class="confluenceTd">Binds the parameter to the message header with the given 
name</td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd">@Headers</td><td colspan="1" rowspan="1" 
class="confluenceTd">Map</td><td colspan="1" rowspan="1" 
class="confluenceTd">Binds the parameter to the message headers. The parameter 
is expected to be of <code>java.util.Map</code> type.</td></tr><tr><td 
colspan="1" rowspan="1" class="confluenceTd">@ExchangeProperty(name)</td><td 
colspan="1" rowspan="1" class="confluenceTd">Object</td><td colspan="1" 
rowspan="1" class="confluenceTd">Binds the parameter to the exchange property 
with the given name</td></tr></tbody></table></div><p>If a param
 eter does not have any annotation then the parameter is bound to the message 
body.</p><p>For example given the following interface</p><div class="code panel 
pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[public interface MyAuditService {
-    void auditMessage(@Header(&quot;uuid&quot;) String uuid, @Body String 
body);
-}]]></script>
-</div></div><p>Then from Java DSL we can create a proxy and call the 
method</p><div class="code panel pdl" style="border-width: 1px;"><div 
class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[// must enable binding on proxy
-MyAuditService service = new 
ProxyBuilder(context).endpoint(&quot;jms:queue:foo&quot;).build(MyAuditService.class);
-service.auditMessage(&quot;1234&quot;, &quot;Hello World&quot;);]]></script>
-</div></div><p>Which will send the message to the JMS queue foo, with the 
header(uuid)=1234 and body=Hello World. The message is sent as InOnly as the 
method is void.</p><p>The old behavior can be enabled by setting binding off, 
such as:</p><div class="code panel pdl" style="border-width: 1px;"><div 
class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[// must enable binding on proxy
-MyAuditService service = new 
ProxyBuilder(context).endpoint(&quot;jms:queue:foo&quot;).binding(false).build(MyAuditService.class);
-service.auditMessage(&quot;1234&quot;, &quot;Hello World&quot;);]]></script>
-</div></div><h3 
id="UsingCamelProxy-TurningtheBeanInvocationintoafirstclasspayload">Turning the 
BeanInvocation into a first class payload</h3><p><strong>Available as of Camel 
2.1</strong></p><p>If you proxied method signature only have one parameter such 
as:</p><div class="code panel pdl" style="border-width: 1px;"><div 
class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[String hello(String name);
-]]></script>
-</div></div><p>Then it gives another advantage in Camel as it allows Camel to 
regard the value passed in to this single parameter as the <em>real</em> 
payload. In other words if you pass in <code>Camel</code> to the hello method, 
then Camel can <em>see</em> that as a <code>java.lang.String</code> payload 
with the value of <code>Camel</code>. This gives you a great advantage as you 
can use the proxy as first class services with Camel.</p><p>You can proxy Camel 
and let clients use the pure and clean interfaces as if Camel newer existed. 
Then Camel can proxy the invocation and receive the input passed into the 
single method parameter and regard that as if it was <em>just</em> the message 
payload.</p><div class="confluence-information-macro 
confluence-information-macro-information"><span class="aui-icon aui-icon-small 
aui-iconfont-info confluence-information-macro-icon"></span><div 
class="confluence-information-macro-body"><p>From&#160;<strong>Camel 
2.16</strong>&#160;onwards this is im
 proved as binding is enabled out of the box, where Camel binds to the message 
parameters using the annotation listed in the table above. If a parameter has 
no annotation then the parameter is bound to the message 
body.</p></div></div><p>&#160;</p><p>Okay lets try that with an example</p><h4 
id="UsingCamelProxy-Examplewithproxyusingsingleparametermethods.">Example with 
proxy using single parameter methods.</h4><p>At first we have the interface we 
wish to proxy</p><div class="code panel pdl" style="border-width: 1px;"><div 
class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
-public interface OrderService {
-
-    String submitOrderStringReturnString(String order);
-
-    Document submitOrderStringReturnDocument(String order);
-
-    String submitOrderDocumentReturnString(Document order);
-
-    Document submitOrderDocumentReturnDocument(Document order);
-
-    void doNothing(String s);
-
-    Integer invalidReturnType(String s);
-
-    String doAbsolutelyNothing();
-
-}
-]]></script>
-</div></div>Notice that all methods have single parameters. The return type is 
optional, as you can see one of them is void.<br clear="none"> Also what you 
should know is that Camel uses its <a shape="rect" 
href="type-converter.html">Type Converter</a> mechanism to adapt to the types 
defined on the methods.<p>This allows us to easily use 
<code>org.w3c.dom.Document</code> and <code>String</code> types with no 
hazzle.</p><p>Okay then we have the following route where we route using a <a 
shape="rect" href="content-based-router.html">Content Based Router</a> that is 
XML based. See that we use <a shape="rect" href="xpath.html">XPath</a> in the 
choices to route the message depending on its a book order or not.</p><div 
class="code panel pdl" style="border-width: 1px;"><div class="codeContent 
panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
-from(&quot;direct:start&quot;)
-        .choice()
-        .when(xpath(&quot;/order/@type = 
&#39;book&#39;&quot;)).to(&quot;direct:book&quot;)
-        .otherwise().to(&quot;direct:other&quot;)
-        .end();
-
-from(&quot;direct:book&quot;).transform(constant(&quot;&lt;order 
id=\&quot;123\&quot;&gt;OK&lt;/order&gt;&quot;));
-
-from(&quot;direct:other&quot;).transform(constant(&quot;&lt;order&gt;FAIL&lt;/order&gt;&quot;));
-]]></script>
-</div></div>Now there is a couple of tests that shows using the Camel Proxy 
how we can easily invoke the proxy and do not know its actually Camel doing 
some routing underneath.<div class="code panel pdl" style="border-width: 
1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
-Endpoint endpoint = context.getEndpoint(&quot;direct:start&quot;);
-OrderService service = ProxyHelper.createProxy(endpoint, OrderService.class);
-
-String reply = service.submitOrderStringReturnString(&quot;&lt;order 
type=\&quot;book\&quot;&gt;Camel in action&lt;/order&gt;&quot;);
-assertEquals(&quot;&lt;order id=\&quot;123\&quot;&gt;OK&lt;/order&gt;&quot;, 
reply);
-]]></script>
-</div></div>And this one below shows using different types that Camel adapts 
to.<div class="code panel pdl" style="border-width: 1px;"><div 
class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
-Endpoint endpoint = context.getEndpoint(&quot;direct:start&quot;);
-OrderService service = ProxyHelper.createProxy(endpoint, OrderService.class);
-
-Document doc = context.getTypeConverter().convertTo(Document.class, 
&quot;&lt;order type=\&quot;book\&quot;&gt;Camel in action&lt;/order&gt;&quot;);
-
-Document reply = service.submitOrderDocumentReturnDocument(doc);
-assertNotNull(reply);
-String s = context.getTypeConverter().convertTo(String.class, reply);
-assertEquals(&quot;&lt;order id=\&quot;123\&quot;&gt;OK&lt;/order&gt;&quot;, 
s);
-]]></script>
-</div></div>Isn't this cool?<h3 
id="UsingCamelProxy-AsynchronoususingFuture">Asynchronous using 
Future</h3><p><strong>Available as of Camel 2.8</strong></p><p>By default the 
<a shape="rect" href="using-camelproxy.html">Camel Proxy</a> invocation is 
synchronous when invoked from the client. If you want this to be asynchronous 
you define the return type to be of <code>java.util.concurrent.Future</code> 
type. The <code>Future</code> is a handle to the task which the client can use 
to obtain the result.</p><p>For example given this client interface</p><div 
class="code panel pdl" style="border-width: 1px;"><div class="codeHeader 
panelHeader pdl" style="border-bottom-width: 1px;"><b>Client 
Interface</b></div><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
-public interface Echo {
-
-    // returning a Future indicate asynchronous invocation
-    Future&lt;String&gt; asText(int number);
-
-}
-]]></script>
-</div></div>The client can use this with a <a shape="rect" 
href="using-camelproxy.html">Camel Proxy</a> as shown from the following 
snippet from an unit test:<div class="code panel pdl" style="border-width: 
1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 
1px;"><b>Using Client</b></div><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
-public void testFutureEcho() throws Exception {
-    Echo service = 
ProxyHelper.createProxy(context.getEndpoint(&quot;direct:echo&quot;), 
Echo.class);
-
-    Future&lt;String&gt; future = service.asText(4);
-    log.info(&quot;Got future&quot;);
-
-    log.info(&quot;Waiting for future to be done ...&quot;);
-    String reply = future.get(5, TimeUnit.SECONDS);
-    assertEquals(&quot;Four&quot;, reply);
-}
-]]></script>
-</div></div>This allows you to fully define your client API without any Camel 
dependency at all, and decide whether the invocation should be synchronous or 
asynchronous.<p>If the Client is asynchronous (return type is Future) then 
Camel will continue processing the invocation using a thread pool which is 
being looked up using the key <code>CamelInvocationHandler</code>. Its a shared 
thread pool for all <a shape="rect" href="using-camelproxy.html">Camel 
Proxy</a> in the <a shape="rect" href="camelcontext.html">CamelContext</a>. You 
can define a <a shape="rect" href="threading-model.html">thread pool 
profile</a> with the id <code>CamelInvocationHandler</code> to configure 
settings such as min/max threads etc.</p><h3 id="UsingCamelProxy-Seealso">See 
also</h3><ul class="alternate"><li><a shape="rect" 
href="bean.html">Bean</a></li><li><a shape="rect" href="user-guide.html">User 
Guide</a></li><li><a shape="rect" 
href="tutorial-jmsremoting.html">Tutorial-JmsRemoting</a></li></ul></div>
+</plain-text-body><p>This basically does the same as 
ProxyHelper.createProxy.</p><h3 
id="UsingCamelProxy-WhatissendontheMessage">What is send on the 
Message</h3><p>When using a proxy Camel will send the message payload as a 
<code>org.apache.camel.component.bean.BeanInvocation</code> object (*Camel 2.15 
or older) which holds the details of which method was invoked and what the 
argument was.&#160;From&#160;<strong style="line-height: 1.4285715;">Camel 
2.16</strong> onwards Camel parameter binding is enabled by default, which will 
use binding information from the method signature parameters to bind to the 
Exchange/Message with the following annotations</p><div 
class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" 
rowspan="1" class="confluenceTh">Annotation</th><th colspan="1" rowspan="1" 
class="confluenceTh">Parameter Type</th><th colspan="1" rowspan="1" 
class="confluenceTh">Parameter binds to</th></tr><tr><td colspan="1" 
rowspan="1" class="confluenceTd">@Body</t
 d><td colspan="1" rowspan="1" class="confluenceTd">Object</td><td colspan="1" 
rowspan="1" class="confluenceTd">Binds the parameter to the message 
body</td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd">@Header(name)</td><td colspan="1" rowspan="1" 
class="confluenceTd">Object</td><td colspan="1" rowspan="1" 
class="confluenceTd">Binds the parameter to the message header with the given 
name</td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd">@Headers</td><td colspan="1" rowspan="1" 
class="confluenceTd">Map</td><td colspan="1" rowspan="1" 
class="confluenceTd">Binds the parameter to the message headers. The parameter 
is expected to be of <code>java.util.Map</code> type.</td></tr><tr><td 
colspan="1" rowspan="1" class="confluenceTd">@ExchangeProperty(name)</td><td 
colspan="1" rowspan="1" class="confluenceTd">Object</td><td colspan="1" 
rowspan="1" class="confluenceTd">Binds the parameter to the exchange property 
with the given name</td></tr></tbody></table></div><p>If a
  parameter does not have any annotation then the parameter is bound to the 
message body.</p><p>For example given the following 
interface</p><plain-text-body>public interface MyAuditService {
+    void auditMessage(@Header("uuid") String uuid, @Body String body);
+}</plain-text-body><p>Then from Java DSL we can create a proxy and call the 
method</p><plain-text-body>// must enable binding on proxy
+MyAuditService service = new 
ProxyBuilder(context).endpoint("jms:queue:foo").build(MyAuditService.class);
+service.auditMessage("1234", "Hello World");</plain-text-body><p>Which will 
send the message to the JMS queue foo, with the header(uuid)=1234 and 
body=Hello World. The message is sent as InOnly as the method is 
void.</p><p>The old behavior can be enabled by setting binding off, such 
as:</p><plain-text-body>// must enable binding on proxy
+MyAuditService service = new 
ProxyBuilder(context).endpoint("jms:queue:foo").binding(false).build(MyAuditService.class);
+service.auditMessage("1234", "Hello World");</plain-text-body><h3 
id="UsingCamelProxy-TurningtheBeanInvocationintoafirstclasspayload">Turning the 
BeanInvocation into a first class payload</h3><p><strong>Available as of Camel 
2.1</strong></p><p>If you proxied method signature only have one parameter such 
as:</p><plain-text-body>String hello(String name);
+</plain-text-body><p>Then it gives another advantage in Camel as it allows 
Camel to regard the value passed in to this single parameter as the 
<em>real</em> payload. In other words if you pass in <code>Camel</code> to the 
hello method, then Camel can <em>see</em> that as a 
<code>java.lang.String</code> payload with the value of <code>Camel</code>. 
This gives you a great advantage as you can use the proxy as first class 
services with Camel.</p><p>You can proxy Camel and let clients use the pure and 
clean interfaces as if Camel newer existed. Then Camel can proxy the invocation 
and receive the input passed into the single method parameter and regard that 
as if it was <em>just</em> the message 
payload.</p><rich-text-body><p>From&#160;<strong>Camel 
2.16</strong>&#160;onwards this is improved as binding is enabled out of the 
box, where Camel binds to the message parameters using the annotation listed in 
the table above. If a parameter has no annotation then the parameter is bound 
to the 
 message body.</p></rich-text-body><p>&#160;</p><p>Okay lets try that with an 
example</p><h4 
id="UsingCamelProxy-Examplewithproxyusingsingleparametermethods.">Example with 
proxy using single parameter methods.</h4><p>At first we have the interface we 
wish to 
proxy<plain-text-body>{snippet:id=e1|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/OrderService.java}</plain-text-body>Notice
 that all methods have single parameters. The return type is optional, as you 
can see one of them is void.<br clear="none"> Also what you should know is that 
Camel uses its <a shape="rect" href="type-converter.html">Type Converter</a> 
mechanism to adapt to the types defined on the methods.</p><p>This allows us to 
easily use <code>org.w3c.dom.Document</code> and <code>String</code> types with 
no hazzle.</p><p>Okay then we have the following route where we route using a 
<a shape="rect" href="content-based-router.html">Content Based Router</a> that 
is XML based. See that we
  use <a shape="rect" href="xpath.html">XPath</a> in the choices to route the 
message depending on its a book order or 
not.<plain-text-body>{snippet:id=e1|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/BeanProxyTest.java}</plain-text-body>Now
 there is a couple of tests that shows using the Camel Proxy how we can easily 
invoke the proxy and do not know its actually Camel doing some routing 
underneath.<plain-text-body>{snippet:id=e2|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/BeanProxyTest.java}</plain-text-body>And
 this one below shows using different types that Camel adapts 
to.<plain-text-body>{snippet:id=e3|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/BeanProxyTest.java}</plain-text-body>Isn't
 this cool?</p><h3 id="UsingCamelProxy-AsynchronoususingFuture">Asynchronous 
using Future</h3><p><strong>Available as of Camel 2.8</strong></p><p>By default 
the <a shape="rect" href=
 "using-camelproxy.html">Camel Proxy</a> invocation is synchronous when invoked 
from the client. If you want this to be asynchronous you define the return type 
to be of <code>java.util.concurrent.Future</code> type. The <code>Future</code> 
is a handle to the task which the client can use to obtain the 
result.</p><p>For example given this client 
interface<plain-text-body>{snippet:id=e1|lang=java|title=Client 
Interface|url=camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/ProxyReturnFutureTest.java}</plain-text-body>The
 client can use this with a <a shape="rect" href="using-camelproxy.html">Camel 
Proxy</a> as shown from the following snippet from an unit 
test:<plain-text-body>{snippet:id=e2|lang=java|title=Using 
Client|url=camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/ProxyReturnFutureTest.java}</plain-text-body>This
 allows you to fully define your client API without any Camel dependency at 
all, and decide whether the invocation should be synch
 ronous or asynchronous.</p><p>If the Client is asynchronous (return type is 
Future) then Camel will continue processing the invocation using a thread pool 
which is being looked up using the key <code>CamelInvocationHandler</code>. Its 
a shared thread pool for all <a shape="rect" href="using-camelproxy.html">Camel 
Proxy</a> in the <a shape="rect" href="camelcontext.html">CamelContext</a>. You 
can define a <a shape="rect" href="threading-model.html">thread pool 
profile</a> with the id <code>CamelInvocationHandler</code> to configure 
settings such as min/max threads etc.</p><h3 id="UsingCamelProxy-Seealso">See 
also</h3><ul class="alternate"><li><a shape="rect" 
href="bean.html">Bean</a></li><li><a shape="rect" href="user-guide.html">User 
Guide</a></li><li><a shape="rect" 
href="tutorial-jmsremoting.html">Tutorial-JmsRemoting</a></li></ul></div>
         </td>
         <td valign="top">
           <div class="navigation">

Modified: websites/production/camel/content/validation.html
==============================================================================
--- websites/production/camel/content/validation.html (original)
+++ websites/production/camel/content/validation.html Fri Aug 25 08:22:01 2017
@@ -36,17 +36,6 @@
     <![endif]-->
 
 
-  <link href='//camel.apache.org/styles/highlighter/styles/shCoreCamel.css' 
rel='stylesheet' type='text/css' />
-  <link href='//camel.apache.org/styles/highlighter/styles/shThemeCamel.css' 
rel='stylesheet' type='text/css' />
-  <script src='//camel.apache.org/styles/highlighter/scripts/shCore.js' 
type='text/javascript'></script>
-  <script src='//camel.apache.org/styles/highlighter/scripts/shBrushJava.js' 
type='text/javascript'></script>
-  <script src='//camel.apache.org/styles/highlighter/scripts/shBrushXml.js' 
type='text/javascript'></script>
-  <script src='//camel.apache.org/styles/highlighter/scripts/shBrushPlain.js' 
type='text/javascript'></script>
-  
-  <script type="text/javascript">
-  SyntaxHighlighter.defaults['toolbar'] = false;
-  SyntaxHighlighter.all();
-  </script>
 
     <title>
     Apache Camel: Validation
@@ -86,39 +75,14 @@
        <tbody>
         <tr>
         <td valign="top" width="100%">
-<div class="wiki-content maincontent"><h2 
id="Validation-ValidationComponent">Validation Component</h2><p>The Validation 
component performs XML validation of the message body using the JAXP Validation 
API and based on any of the supported XML schema languages, which defaults to 
<a shape="rect" class="external-link" href="http://www.w3.org/XML/Schema"; 
rel="nofollow">XML Schema</a></p><p>Note that the <a shape="rect" 
href="jing.html">Jing</a> component also supports the following useful schema 
languages:</p><ul><li><a shape="rect" class="external-link" 
href="http://relaxng.org/compact-tutorial-20030326.html"; rel="nofollow">RelaxNG 
Compact Syntax</a></li><li><a shape="rect" class="external-link" 
href="http://relaxng.org/"; rel="nofollow">RelaxNG XML 
Syntax</a></li></ul><p>The <a shape="rect" href="msv.html">MSV</a> component 
also supports <a shape="rect" class="external-link" href="http://relaxng.org/"; 
rel="nofollow">RelaxNG XML Syntax</a>.</p><h3 id="Validation-URIformat">URI 
format</h
 3><div class="code panel pdl" style="border-width: 1px;"><div 
class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[validator:someLocalOrRemoteResource
-]]></script>
-</div></div><p>Where <strong>someLocalOrRemoteResource</strong> is some URL to 
a local resource on the classpath or a full URL to a remote resource or 
resource on the file system which contains the XSD to validate against. For 
example:</p><ul><li><code>msv:org/foo/bar.xsd</code></li><li><code>msv:file:../foo/bar.xsd</code></li><li><code>msv:<a
 shape="rect" class="external-link" href="http://acme.com/cheese.xsd"; 
rel="nofollow">http://acme.com/cheese.xsd</a></code></li><li><code>validator:com/mypackage/myschema.xsd</code></li></ul><p>Maven
 users will need to add the following dependency to their <code>pom.xml</code> 
for this component when using <strong>Camel 2.8</strong> or older:</p><div 
class="code panel pdl" style="border-width: 1px;"><div class="codeContent 
panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[&lt;dependency&gt;
+<div class="wiki-content maincontent"><h2 
id="Validation-ValidationComponent">Validation Component</h2><p>The Validation 
component performs XML validation of the message body using the JAXP Validation 
API and based on any of the supported XML schema languages, which defaults to 
<a shape="rect" class="external-link" href="http://www.w3.org/XML/Schema"; 
rel="nofollow">XML Schema</a></p><p>Note that the <a shape="rect" 
href="jing.html">Jing</a> component also supports the following useful schema 
languages:</p><ul><li><a shape="rect" class="external-link" 
href="http://relaxng.org/compact-tutorial-20030326.html"; rel="nofollow">RelaxNG 
Compact Syntax</a></li><li><a shape="rect" class="external-link" 
href="http://relaxng.org/"; rel="nofollow">RelaxNG XML 
Syntax</a></li></ul><p>The <a shape="rect" href="msv.html">MSV</a> component 
also supports <a shape="rect" class="external-link" href="http://relaxng.org/"; 
rel="nofollow">RelaxNG XML Syntax</a>.</p><h3 id="Validation-URIformat">URI 
format</h
 3><plain-text-body>validator:someLocalOrRemoteResource
+</plain-text-body><p>Where <strong>someLocalOrRemoteResource</strong> is some 
URL to a local resource on the classpath or a full URL to a remote resource or 
resource on the file system which contains the XSD to validate against. For 
example:</p><ul><li><code>msv:org/foo/bar.xsd</code></li><li><code>msv:file:../foo/bar.xsd</code></li><li><code>msv:<a
 shape="rect" class="external-link" href="http://acme.com/cheese.xsd"; 
rel="nofollow">http://acme.com/cheese.xsd</a></code></li><li><code>validator:com/mypackage/myschema.xsd</code></li></ul><p>Maven
 users will need to add the following dependency to their <code>pom.xml</code> 
for this component when using <strong>Camel 2.8</strong> or 
older:</p><parameter 
ac:name="">xml</parameter><plain-text-body>&lt;dependency&gt;
     &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
     &lt;artifactId&gt;camel-spring&lt;/artifactId&gt;
     &lt;version&gt;x.x.x&lt;/version&gt;
     &lt;!-- use the same version as your Camel core version --&gt;
 &lt;/dependency&gt;
-]]></script>
-</div></div><p>From Camel 2.9 onwards the <a shape="rect" 
href="validation.html">Validation</a> component is provided directly in the 
camel-core.</p><h3 id="Validation-Options">Options</h3><div 
class="confluenceTableSmall"><div class="table-wrap"><table 
class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" 
class="confluenceTh"><p>Option</p></th><th colspan="1" rowspan="1" 
class="confluenceTh"><p>Default</p></th><th colspan="1" rowspan="1" 
class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" 
rowspan="1" class="confluenceTd">resourceResolverFactory</td><td colspan="1" 
rowspan="1" 
class="confluenceTd">DefaultValidatorResourceResolverFactory</td><td 
colspan="1" rowspan="1" class="confluenceTd"><strong>Camel 2.17</strong>: 
Reference to a 
<code>org.apache.camel.component.validator.ValidatorResourceResolverFactory 
</code>which creates a resource resolver per endpoint<code>. </code><span>The 
default implementation creates an instance of <code><span>org.apache.camel.
 component.validator.</span>DefaultLSResourceResolver per endpoint 
</code></span><span><span>which creates the default resource resolver 
<code><span>org.apache.camel.component.validator.</span>DefaultLSResourceResolver.
 The default resource resolver</code> reads the schema files from the classpath 
and the file system. This option instead of the option 
<code>resourceResolver</code> shall be used when the resource resolver depends 
on the resource URI of the root schema document specified in the endpoint; for 
example, if you want to extend the default resource resolver. This option is 
also available on the validator component, so that you can set the resource 
resolver factory only once for all endpoints.</span></span></td></tr><tr><td 
colspan="1" rowspan="1" 
class="confluenceTd"><p><code>resourceResolver</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><strong>Camel 2.9:</strong> Reference to
  a <code>org.w3c.dom.ls.LSResourceResolver</code> in the <a shape="rect" 
href="registry.html">Registry</a>.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>useDom</code></p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>false</code></p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>Whether <code>DOMSource</code>/<code>DOMResult</code> 
or <code>SaxSource</code>/<code>SaxResult</code> should be used by the 
validator.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>useSharedSchema</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><strong>Camel 2.3:</strong> Whether the 
<code>Schema</code> instance should be shared or not. This option is introduced 
to work around a <a shape="rect" class="external-link" 
href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6773084"; 
rel="nofollow">JDK 1.6.x bug</a>. Xerces should 
 not have this issue.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>failOnNullBody</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><strong>Camel 2.9.5/2.10.3:</strong> 
Whether to fail if no body exists.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>headerName</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><strong>Camel 2.11:</strong> To validate 
against a header instead of the message body.</p></td></tr><tr><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code>failOnNullHeader</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.11:</strong> 
Whether to fail if no header exists when validating against a 
header.</p></td></tr></
 tbody></table></div></div>
-
-
-<h3 id="Validation-Example">Example</h3><p>The following <a shape="rect" 
class="external-link" 
href="http://svn.apache.org/repos/asf/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/validator/camelContext.xml";>example</a>
 shows how to configure a route from endpoint <strong>direct:start</strong> 
which then goes to one of two endpoints, either <strong>mock:valid</strong> or 
<strong>mock:invalid</strong> based on whether or not the XML matches the given 
schema (which is supplied on the classpath).</p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
-&lt;route&gt;
-    &lt;from uri=&quot;direct:start&quot;/&gt;
-    &lt;doTry&gt;
-        &lt;to 
uri=&quot;validator:org/apache/camel/component/validator/schema.xsd&quot;/&gt;
-        &lt;to uri=&quot;mock:valid&quot;/&gt;
-        &lt;doCatch&gt;
-            
&lt;exception&gt;org.apache.camel.ValidationException&lt;/exception&gt;
-            &lt;to uri=&quot;mock:invalid&quot;/&gt;
-        &lt;/doCatch&gt;
-        &lt;doFinally&gt;
-            &lt;to uri=&quot;mock:finally&quot;/&gt;
-        &lt;/doFinally&gt;
-    &lt;/doTry&gt;
-&lt;/route&gt;
-]]></script>
-</div></div><h3 id="Validation-Advanced:JMXmethodclearCachedSchema">Advanced: 
JMX method clearCachedSchema</h3><p>Since <strong>Camel 2.17</strong>, you can 
force that the cached schema in the validator endpoint is cleared and reread 
with the next process call with the JMX operation&#160;<code>clearCachedSchema. 
</code>You can also use this method to programmatically clear the cache. This 
method is available on the <code>ValidatorEndpoint 
</code>class<code>.</code></p><h3 
id="Validation-Advanced:GlobalOption&quot;CamelXmlValidatorAccessExternalDTD&quot;">Advanced:
 Global Option "CamelXmlValidatorAccessExternalDTD"</h3><p>Since <strong>Camel 
2.19, 2.18.3, and &#160;2.17.6</strong> the default schema factory no longer 
allows reading external DTDs and external DTD entities. To achieve the old 
behavior where it was possible to access external DTDs and DTDs entities you 
can set the CamelContext global option 
&#160;"CamelXmlValidatorAccessExternalDTD" to "true". Prior to 2.19 global optio
 ns where called properties.</p><p></p><h3 id="Validation-SeeAlso">See Also</h3>
-<ul><li><a shape="rect" href="configuring-camel.html">Configuring 
Camel</a></li><li><a shape="rect" 
href="component.html">Component</a></li><li><a shape="rect" 
href="endpoint.html">Endpoint</a></li><li><a shape="rect" 
href="getting-started.html">Getting Started</a></li></ul></div>
+</plain-text-body><p>From Camel 2.9 onwards the <a shape="rect" 
href="validation.html">Validation</a> component is provided directly in the 
camel-core.</p><h3 id="Validation-Options">Options</h3><parameter 
ac:name="class">confluenceTableSmall</parameter><rich-text-body><div 
class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" 
rowspan="1" class="confluenceTh"><p>Option</p></th><th colspan="1" rowspan="1" 
class="confluenceTh"><p>Default</p></th><th colspan="1" rowspan="1" 
class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" 
rowspan="1" class="confluenceTd">resourceResolverFactory</td><td colspan="1" 
rowspan="1" 
class="confluenceTd">DefaultValidatorResourceResolverFactory</td><td 
colspan="1" rowspan="1" class="confluenceTd"><strong>Camel 2.17</strong>: 
Reference to a 
<code>org.apache.camel.component.validator.ValidatorResourceResolverFactory 
</code>which creates a resource resolver per endpoint<code>. </code><span>The 
default implementation creat
 es an instance of 
<code><span>org.apache.camel.component.validator.</span>DefaultLSResourceResolver
 per endpoint </code></span><span><span>which creates the default resource 
resolver 
<code><span>org.apache.camel.component.validator.</span>DefaultLSResourceResolver.
 The default resource resolver</code> reads the schema files from the classpath 
and the file system. This option instead of the option 
<code>resourceResolver</code> shall be used when the resource resolver depends 
on the resource URI of the root schema document specified in the endpoint; for 
example, if you want to extend the default resource resolver. This option is 
also available on the validator component, so that you can set the resource 
resolver factory only once for all endpoints.</span></span></td></tr><tr><td 
colspan="1" rowspan="1" 
class="confluenceTd"><p><code>resourceResolver</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td colspan="1" 
rowspan="1" class="confluence
 Td"><p><strong>Camel 2.9:</strong> Reference to a 
<code>org.w3c.dom.ls.LSResourceResolver</code> in the <a shape="rect" 
href="registry.html">Registry</a>.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>useDom</code></p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>false</code></p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>Whether <code>DOMSource</code>/<code>DOMResult</code> 
or <code>SaxSource</code>/<code>SaxResult</code> should be used by the 
validator.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>useSharedSchema</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><strong>Camel 2.3:</strong> Whether the 
<code>Schema</code> instance should be shared or not. This option is introduced 
to work around a <a shape="rect" class="external-link" 
href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6773084"; r
 el="nofollow">JDK 1.6.x bug</a>. Xerces should not have this 
issue.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>failOnNullBody</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><strong>Camel 2.9.5/2.10.3:</strong> 
Whether to fail if no body exists.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>headerName</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><strong>Camel 2.11:</strong> To validate 
against a header instead of the message body.</p></td></tr><tr><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code>failOnNullHeader</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.11:</strong> 
Whether to fail if no header exists wh
 en validating against a 
header.</p></td></tr></tbody></table></div></rich-text-body><h3 
id="Validation-Example">Example</h3><p>The following <a shape="rect" 
class="external-link" 
href="http://svn.apache.org/repos/asf/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/validator/camelContext.xml";>example</a>
 shows how to configure a route from endpoint <strong>direct:start</strong> 
which then goes to one of two endpoints, either <strong>mock:valid</strong> or 
<strong>mock:invalid</strong> based on whether or not the XML matches the given 
schema (which is supplied on the 
classpath).<plain-text-body>{snippet:id=example|lang=xml|url=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/validator/camelContext.xml}</plain-text-body></p><h3
 id="Validation-Advanced:JMXmethodclearCachedSchema">Advanced: JMX method 
clearCachedSchema</h3><p>Since <strong>Camel 2.17</strong>, you can force that 
the cached schema in the validator endpoint
  is cleared and reread with the next process call with the JMX 
operation&#160;<code>clearCachedSchema. </code>You can also use this method to 
programmatically clear the cache. This method is available on the 
<code>ValidatorEndpoint </code>class<code>.</code></p><h3 
id="Validation-Advanced:GlobalOption&quot;CamelXmlValidatorAccessExternalDTD&quot;">Advanced:
 Global Option "CamelXmlValidatorAccessExternalDTD"</h3><p>Since <strong>Camel 
2.19, 2.18.3, and &#160;2.17.6</strong> the default schema factory no longer 
allows reading external DTDs and external DTD entities. To achieve the old 
behavior where it was possible to access external DTDs and DTDs entities you 
can set the CamelContext global option 
&#160;"CamelXmlValidatorAccessExternalDTD" to "true". Prior to 2.19 global 
options where called properties.</p><p><parameter ac:name=""><a shape="rect" 
href="endpoint-see-also.html">Endpoint See Also</a></parameter></p></div>
         </td>
         <td valign="top">
           <div class="navigation">

Modified: websites/production/camel/content/walk-through-an-example.html
==============================================================================
--- websites/production/camel/content/walk-through-an-example.html (original)
+++ websites/production/camel/content/walk-through-an-example.html Fri Aug 25 
08:22:01 2017
@@ -36,17 +36,6 @@
     <![endif]-->
 
 
-  <link href='//camel.apache.org/styles/highlighter/styles/shCoreCamel.css' 
rel='stylesheet' type='text/css' />
-  <link href='//camel.apache.org/styles/highlighter/styles/shThemeCamel.css' 
rel='stylesheet' type='text/css' />
-  <script src='//camel.apache.org/styles/highlighter/scripts/shCore.js' 
type='text/javascript'></script>
-  <script src='//camel.apache.org/styles/highlighter/scripts/shBrushJava.js' 
type='text/javascript'></script>
-  <script src='//camel.apache.org/styles/highlighter/scripts/shBrushXml.js' 
type='text/javascript'></script>
-  <script src='//camel.apache.org/styles/highlighter/scripts/shBrushPlain.js' 
type='text/javascript'></script>
-  
-  <script type="text/javascript">
-  SyntaxHighlighter.defaults['toolbar'] = false;
-  SyntaxHighlighter.all();
-  </script>
 
     <title>
     Apache Camel: Walk through an Example
@@ -86,38 +75,8 @@
        <tbody>
         <tr>
         <td valign="top" width="100%">
-<div class="wiki-content maincontent"><h2 
id="WalkthroughanExample-WalkthroughanExampleCode">Walk through an Example 
Code</h2><p>This mini-guide takes you through the source code of a <a 
shape="rect" class="external-link" 
href="https://svn.apache.org/repos/asf/camel/trunk/examples/camel-example-jms-file/src/main/java/org/apache/camel/example/jmstofile/CamelJmsToFileExample.java";>simple
 example</a>.</p><p>Camel can be configured either by using <a shape="rect" 
href="spring.html">Spring</a> or directly in Java - which <a shape="rect" 
class="external-link" 
href="https://svn.apache.org/repos/asf/camel/trunk/examples/camel-example-jms-file/src/main/java/org/apache/camel/example/jmstofile/CamelJmsToFileExample.java";>this
 example does</a>.</p><p>This example is available in the 
<code>examples\camel-example-jms-file</code> directory of the <a shape="rect" 
href="download.html">Camel distribution</a>.</p><p>We start with creating a <a 
shape="rect" href="camelcontext.html">CamelContext</a> - w
 hich is a container for <a shape="rect" href="components.html">Components</a>, 
<a shape="rect" href="routes.html">Routes</a> etc:</p><div class="code panel 
pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
-CamelContext context = new DefaultCamelContext();
-]]></script>
-</div></div>There is more than one way of adding a Component to the 
CamelContext. You can add components implicitly - when we set up the routing - 
as we do here for the <a shape="rect" href="file2.html">FileComponent</a>:<div 
class="code panel pdl" style="border-width: 1px;"><div class="codeContent 
panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
-context.addRoutes(new RouteBuilder() {
-    public void configure() {
-        
from(&quot;test-jms:queue:test.queue&quot;).to(&quot;file://test&quot;);
-    }
-});
-]]></script>
-</div></div>or explicitly - as we do here when we add the JMS Component:<div 
class="code panel pdl" style="border-width: 1px;"><div class="codeContent 
panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
-ConnectionFactory connectionFactory = new 
ActiveMQConnectionFactory(&quot;vm://localhost?broker.persistent=false&quot;);
-// Note we can explicit name the component
-context.addComponent(&quot;test-jms&quot;, 
JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));
-]]></script>
-</div></div>The above works with any JMS provider. If we know we are using <a 
shape="rect" href="activemq.html">ActiveMQ</a> we can use an even simpler form 
using the <a shape="rect" class="external-link" 
href="http://activemq.apache.org/maven/5.5.0/activemq-camel/apidocs/org/apache/activemq/camel/component/ActiveMQComponent.html#activeMQComponent%28java.lang.String%29";><code>activeMQComponent()</code>
 method</a> while specifying the <a shape="rect" class="external-link" 
href="http://activemq.apache.org/configuring-transports.html";>brokerURL</a> 
used to connect to ActiveMQ<p>In normal use, an external system would be firing 
messages or events directly into Camel through one if its <a shape="rect" 
href="components.html">Components</a> but we are going to use the <a 
shape="rect" class="external-link" 
href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/ProducerTemplate.html";>ProducerTemplate</a>
 which is a really easy way for testing your configuration:</p><
 div class="code panel pdl" style="border-width: 1px;"><div class="codeContent 
panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
-ProducerTemplate template = context.createProducerTemplate();
-]]></script>
-</div></div>Next you <strong>must</strong> start the camel context. If you are 
using <a shape="rect" href="spring.html">Spring</a> to configure the camel 
context this is automatically done for you; though if you are using a pure Java 
approach then you just need to call the start() method<div class="code panel 
pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[camelContext.start();
-]]></script>
-</div></div><p>This will start all of the configured routing rules.</p><p>So 
after starting the <a shape="rect" href="camelcontext.html">CamelContext</a>, 
we can fire some objects into camel:</p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
-for (int i = 0; i &lt; 10; i++) {
-    template.sendBody(&quot;test-jms:queue:test.queue&quot;, &quot;Test 
Message: &quot; + i);
-}
-]]></script>
-</div></div><h2 id="WalkthroughanExample-Whathappens?">What 
happens?</h2><p>From the <a shape="rect" class="external-link" 
href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/ProducerTemplate.html";>ProducerTemplate</a>
 - we send objects (in this case text) into the <a shape="rect" 
href="camelcontext.html">CamelContext</a> to the Component 
<em>test-jms:queue:test.queue</em>. These text objects will be <a shape="rect" 
href="type-converter.html">converted automatically</a> into JMS Messages and 
posted to a JMS Queue named <em>test.queue</em>. When we set up the <a 
shape="rect" href="routes.html">Route</a>, we configured the <a shape="rect" 
href="file2.html">FileComponent</a> to listen off the 
<em>test.queue</em>.</p><p>The File <a shape="rect" 
href="file2.html">FileComponent</a> will take messages off the Queue, and save 
them to a directory named <em>test</em>. Every message will be saved in a file 
that corresponds to its destination and message id.</p><p>Fi
 nally, we configured our own listener in the <a shape="rect" 
href="routes.html">Route</a> - to take notifications from the <a shape="rect" 
href="file2.html">FileComponent</a> and print them out as 
text.</p><p><strong>That's it!</strong></p><p>If you have the time then use 5 
more minutes to <a shape="rect" href="walk-through-another-example.html">Walk 
through another example</a> that demonstrates the Spring DSL (XML based) 
routing.</p></div>
+<div class="wiki-content maincontent"><h2 
id="WalkthroughanExample-WalkthroughanExampleCode">Walk through an Example 
Code</h2><p>This mini-guide takes you through the source code of a <a 
shape="rect" class="external-link" 
href="https://svn.apache.org/repos/asf/camel/trunk/examples/camel-example-jms-file/src/main/java/org/apache/camel/example/jmstofile/CamelJmsToFileExample.java";>simple
 example</a>.</p><p>Camel can be configured either by using <a shape="rect" 
href="spring.html">Spring</a> or directly in Java - which <a shape="rect" 
class="external-link" 
href="https://svn.apache.org/repos/asf/camel/trunk/examples/camel-example-jms-file/src/main/java/org/apache/camel/example/jmstofile/CamelJmsToFileExample.java";>this
 example does</a>.</p><p>This example is available in the 
<code>examples\camel-example-jms-file</code> directory of the <a shape="rect" 
href="download.html">Camel distribution</a>.</p><p>We start with creating a <a 
shape="rect" href="camelcontext.html">CamelContext</a> - w
 hich is a container for <a shape="rect" href="components.html">Components</a>, 
<a shape="rect" href="routes.html">Routes</a> 
etc:<plain-text-body>{snippet:id=e1|lang=java|url=camel/trunk/examples/camel-example-jms-file/src/main/java/org/apache/camel/example/jmstofile/CamelJmsToFileExample.java}</plain-text-body>There
 is more than one way of adding a Component to the CamelContext. You can add 
components implicitly - when we set up the routing - as we do here for the <a 
shape="rect" 
href="file2.html">FileComponent</a>:<plain-text-body>{snippet:id=e3|lang=java|url=camel/trunk/examples/camel-example-jms-file/src/main/java/org/apache/camel/example/jmstofile/CamelJmsToFileExample.java}</plain-text-body>or
 explicitly - as we do here when we add the JMS 
Component:<plain-text-body>{snippet:id=e2|lang=java|url=camel/trunk/examples/camel-example-jms-file/src/main/java/org/apache/camel/example/jmstofile/CamelJmsToFileExample.java}</plain-text-body>The
 above works with any JMS provider. If we kn
 ow we are using <a shape="rect" href="activemq.html">ActiveMQ</a> we can use 
an even simpler form using the <a shape="rect" class="external-link" 
href="http://activemq.apache.org/maven/5.5.0/activemq-camel/apidocs/org/apache/activemq/camel/component/ActiveMQComponent.html#activeMQComponent%28java.lang.String%29";><code>activeMQComponent()</code>
 method</a> while specifying the <a shape="rect" class="external-link" 
href="http://activemq.apache.org/configuring-transports.html";>brokerURL</a> 
used to connect to ActiveMQ</p><p>In normal use, an external system would be 
firing messages or events directly into Camel through one if its <a 
shape="rect" href="components.html">Components</a> but we are going to use the 
<a shape="rect" class="external-link" 
href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/ProducerTemplate.html";>ProducerTemplate</a>
 which is a really easy way for testing your 
configuration:<plain-text-body>{snippet:id=e4|lang=java|url=camel/trunk/ex
 
amples/camel-example-jms-file/src/main/java/org/apache/camel/example/jmstofile/CamelJmsToFileExample.java}</plain-text-body>Next
 you <strong>must</strong> start the camel context. If you are using <a 
shape="rect" href="spring.html">Spring</a> to configure the camel context this 
is automatically done for you; though if you are using a pure Java approach 
then you just need to call the start() 
method</p><plain-text-body>camelContext.start();
+</plain-text-body><p>This will start all of the configured routing 
rules.</p><p>So after starting the <a shape="rect" 
href="camelcontext.html">CamelContext</a>, we can fire some objects into 
camel:<plain-text-body>{snippet:id=e5|lang=java|url=camel/trunk/examples/camel-example-jms-file/src/main/java/org/apache/camel/example/jmstofile/CamelJmsToFileExample.java}</plain-text-body></p><h2
 id="WalkthroughanExample-Whathappens?">What happens?</h2><p>From the <a 
shape="rect" class="external-link" 
href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/ProducerTemplate.html";>ProducerTemplate</a>
 - we send objects (in this case text) into the <a shape="rect" 
href="camelcontext.html">CamelContext</a> to the Component 
<em>test-jms:queue:test.queue</em>. These text objects will be <a shape="rect" 
href="type-converter.html">converted automatically</a> into JMS Messages and 
posted to a JMS Queue named <em>test.queue</em>. When we set up the <a 
shape="rect" href="routes.ht
 ml">Route</a>, we configured the <a shape="rect" 
href="file2.html">FileComponent</a> to listen off the 
<em>test.queue</em>.</p><p>The File <a shape="rect" 
href="file2.html">FileComponent</a> will take messages off the Queue, and save 
them to a directory named <em>test</em>. Every message will be saved in a file 
that corresponds to its destination and message id.</p><p>Finally, we 
configured our own listener in the <a shape="rect" href="routes.html">Route</a> 
- to take notifications from the <a shape="rect" 
href="file2.html">FileComponent</a> and print them out as 
text.</p><p><strong>That's it!</strong></p><p>If you have the time then use 5 
more minutes to <a shape="rect" href="walk-through-another-example.html">Walk 
through another example</a> that demonstrates the Spring DSL (XML based) 
routing.</p></div>
         </td>
         <td valign="top">
           <div class="navigation">

Modified: 
websites/production/camel/content/why-is-my-processor-not-showing-up-in-jconsole.html
==============================================================================
--- 
websites/production/camel/content/why-is-my-processor-not-showing-up-in-jconsole.html
 (original)
+++ 
websites/production/camel/content/why-is-my-processor-not-showing-up-in-jconsole.html
 Fri Aug 25 08:22:01 2017
@@ -36,17 +36,6 @@
     <![endif]-->
 
 
-  <link href='//camel.apache.org/styles/highlighter/styles/shCoreCamel.css' 
rel='stylesheet' type='text/css' />
-  <link href='//camel.apache.org/styles/highlighter/styles/shThemeCamel.css' 
rel='stylesheet' type='text/css' />
-  <script src='//camel.apache.org/styles/highlighter/scripts/shCore.js' 
type='text/javascript'></script>
-  <script src='//camel.apache.org/styles/highlighter/scripts/shBrushJava.js' 
type='text/javascript'></script>
-  <script src='//camel.apache.org/styles/highlighter/scripts/shBrushXml.js' 
type='text/javascript'></script>
-  <script src='//camel.apache.org/styles/highlighter/scripts/shBrushPlain.js' 
type='text/javascript'></script>
-  
-  <script type="text/javascript">
-  SyntaxHighlighter.defaults['toolbar'] = false;
-  SyntaxHighlighter.all();
-  </script>
 
     <title>
     Apache Camel: Why is my processor not showing up in JConsole
@@ -95,67 +84,14 @@ For example, the minor ones such as <cod
 
 <p>From <strong>Camel 2.6</strong> onwards your custom <code>Processor</code> 
should use the Spring JMX annotations (for <strong>Camel 2.9</strong> onwards 
see the tip box below). Just add <code>@ManagedResource</code> to the class, 
and the other annotations for the attributes and operations. Then Camel will 
automatically use those when the processor is being registered in JMX.</p>
 
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader 
panelHeader pdl" style="border-bottom-width: 1px;"><b>Custom 
processor</b></div><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
-@ManagedResource(description = &quot;My Managed Component&quot;)
-public static class MyCustomProcessor extends ServiceSupport implements 
Processor {
-    private String foo = &quot;hey&quot;;
-
-    @ManagedAttribute
-    public String getFoo() {
-        return foo;
-    }
-
-    @ManagedAttribute
-    public void setFoo(String foo) {
-        this.foo = foo;
-    }
-
-    public void process(Exchange exchange) throws Exception {
-        exchange.getIn().setHeader(&quot;foo&quot;, getFoo());
-    }
-
-    @Override
-    protected void doStart() throws Exception {
-        // noop
-    }
-
-    @Override
-    protected void doStop() throws Exception {
-        // noop
-    }
-}
-]]></script>
-</div></div>
+<plain-text-body>{snippet:id=e1|lang=java|title=Custom 
processor|url=camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedCustomProcessorTest.java}</plain-text-body>
 
 <p>The same applies when using beans in your routes.</p>
 
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader 
panelHeader pdl" style="border-bottom-width: 1px;"><b>Custom bean</b></div><div 
class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
-@ManagedResource(description = &quot;My Managed Bean&quot;)
-public static class MyCustomBean {
-    private String foo = &quot;hey&quot;;
-
-    @ManagedAttribute
-    public String getFoo() {
-        return foo;
-    }
-
-    @ManagedAttribute
-    public void setFoo(String foo) {
-        this.foo = foo;
-    }
-
-    public String doSomething(String body, @Headers Map&lt;Object, Object&gt; 
headers) throws Exception {
-        headers.put(&quot;foo&quot;, foo);
-        return &quot;Hello &quot; + body;
-    }
-}
-]]></script>
-</div></div>
+<plain-text-body>{snippet:id=e1|lang=java|title=Custom 
bean|url=camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedCustomBeanTest.java}</plain-text-body>
 
-<div class="confluence-information-macro confluence-information-macro-tip"><p 
class="title">Camel 2.9 onwards provides Camel's own JMX annotations</p><span 
class="aui-icon aui-icon-small aui-iconfont-approve 
confluence-information-macro-icon"></span><div 
class="confluence-information-macro-body">
-<p>Notice that from Camel 2.9 onwards its encouraged to use the 
<code>@ManagedResource</code>, <code>@ManagedAttribute</code> and 
<code>@ManagedOperation</code> from the 
<code>org.apache.camel.api.management</code> package. This allows your custom 
code to not depend on Spring JARs anymore.</p></div></div>
+<parameter ac:name="title">Camel 2.9 onwards provides Camel's own JMX 
annotations</parameter><rich-text-body>
+<p>Notice that from Camel 2.9 onwards its encouraged to use the 
<code>@ManagedResource</code>, <code>@ManagedAttribute</code> and 
<code>@ManagedOperation</code> from the 
<code>org.apache.camel.api.management</code> package. This allows your custom 
code to not depend on Spring JARs anymore.</p></rich-text-body>
 
 <h3 id="WhyismyprocessornotshowingupinJConsole-Seealso">See also</h3>
 <ul class="alternate"><li><a shape="rect" href="camel-jmx.html">Camel 
JMX</a></li></ul></div>


Reply via email to