camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Camel > ControlBus Component
Date Thu, 01 Nov 2012 15:32:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/2042/9/1/_/styles/combined.css?spaceKey=CAMEL&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/CAMEL/ControlBus+Component">ControlBus
Component</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~davsclaus">Claus
Ibsen</a>
    </h4>
        <br/>
                         <h4>Changes (4)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >{div:class=confluenceTableSmall} <br>||
Command || Description || <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">|
{{route}} | To control routes using the {{routeId}} and {{action}} parameter. | <br></td></tr>
            <tr><td class="diff-unchanged" >| {{language}} | Allows to specify
a [Language] to use for evaluating the message body. If there is any result from the evaluation,
then the result is put on the message body. | <br>{div} <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >{div:class=confluenceTableSmall} <br>||
Name || Default Value || Description || <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">|
{{routeId}} | {{null}} | To specify a route by its id. | <br>| {{action}} | {{null}}
| To denote an action which can be either: {{start}}, {{stop}}, or {{status}}. To either start
or stop a route. Og get the status of the route as output to the message body. | <br></td></tr>
            <tr><td class="diff-unchanged" >{div} <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >h3. Samples <br> <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">h4.
Using route command <br> <br>The route command allows to do common tasks on a
given route very easily, for example to start a route you can send a empty message to this
endpoint: <br>{code} <br>template.sendBody(&quot;controlbus:route?routeId=foo&amp;action=start&quot;,
null); <br>{code} <br> <br>To get the status of the route you can do: <br>{code}
<br>String status = template.requestBody(&quot;controlbus:route?routeId=foo&amp;action=status&quot;,
null, String.class); <br>{code} <br> <br> <br></td></tr>
            <tr><td class="diff-unchanged" >h4. Using [Simple] language <br>
<br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >{code} <br> <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">{tip}
<br>You can also use other languages such as [Groovy] etc. <br>{tip} <br></td></tr>
            <tr><td class="diff-unchanged" > <br>{include:Endpoint See Also}
<br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h2><a name="ControlBusComponent-ControlBusComponent"></a>ControlBus
Component</h2>
<p><b>Available as of Camel 2.11</b></p>

<p>The <b>controlbus:</b> component provides direct, synchronous invocation
of any consumers when a producer sends a message exchange.<br/>
This endpoint can be used to connect existing routes in the <b>same</b> camel
context.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
controlbus:command[?options]
</pre>
</div></div>

<p>Where <b>command</b> can be any string to identify which type of command
to use.</p>

<h3><a name="ControlBusComponent-Commands"></a>Commands </h3>
<div class="confluenceTableSmall"><div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Command </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>route</tt> </td>
<td class='confluenceTd'> To control routes using the <tt>routeId</tt> and
<tt>action</tt> parameter. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>language</tt> </td>
<td class='confluenceTd'> Allows to specify a <a href="/confluence/display/CAMEL/Language"
title="Language">Language</a> to use for evaluating the message body. If there is
any result from the evaluation, then the result is put on the message body. </td>
</tr>
</tbody></table>
</div>
</div>

<h3><a name="ControlBusComponent-Options"></a>Options</h3>
<div class="confluenceTableSmall"><div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Default Value </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>routeId</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> To specify a route by its id. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>action</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> To denote an action which can be either: <tt>start</tt>,
<tt>stop</tt>, or <tt>status</tt>. To either start or stop a route.
Og get the status of the route as output to the message body. </td>
</tr>
</tbody></table>
</div>
</div>

<p>You can append query options to the URI in the following format, <tt>?option=value&amp;option=value&amp;...</tt></p>

<h3><a name="ControlBusComponent-Samples"></a>Samples</h3>

<h4><a name="ControlBusComponent-Usingroutecommand"></a>Using route command</h4>

<p>The route command allows to do common tasks on a given route very easily, for example
to start a route you can send a empty message to this endpoint:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
template.sendBody(<span class="code-quote">"controlbus:route?routeId=foo&amp;action=start"</span>,
<span class="code-keyword">null</span>);
</pre>
</div></div>

<p>To get the status of the route you can do:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
<span class="code-object">String</span> status = template.requestBody(<span
class="code-quote">"controlbus:route?routeId=foo&amp;action=status"</span>, <span
class="code-keyword">null</span>, <span class="code-object">String</span>.class);
</pre>
</div></div>


<h4><a name="ControlBusComponent-UsingSimplelanguage"></a>Using <a href="/confluence/display/CAMEL/Simple"
title="Simple">Simple</a> language</h4>

<p>You can use <a href="/confluence/display/CAMEL/Simple" title="Simple">Simple</a>
language with the control bus, for example to stop a specific route you can send a message
to the <tt>"controlbus:language:simple"</tt> endpoint containing the following
message:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
template.sendBody(<span class="code-quote">"controlbus:language:simple"</span>,
<span class="code-quote">"${camelContext.stopRoute('myRoute')}"</span>);
</pre>
</div></div>

<p>As this operation is a void operation, then no result is returned. However if you
want the route status you can do:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
<span class="code-object">String</span> status = template.requestBody(<span
class="code-quote">"controlbus:language:simple"</span>, <span class="code-quote">"${camelContext.getRouteStatus('myRoute')}"</span>,
<span class="code-object">String</span>.class);
</pre>
</div></div>

<div class='panelMacro'><table class='tipMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/check.gif" width="16" height="16"
align="absmiddle" alt="" border="0"></td><td>You can also use other languages
such as <a href="/confluence/display/CAMEL/Groovy" title="Groovy">Groovy</a> etc.</td></tr></table></div>

<h3><a name="ControlBusComponent-SeeAlso"></a>See Also</h3>
<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring
Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting
Started</a></li>
</ul>

<ul class="alternate" type="square">
	<li><a href="/confluence/display/CAMEL/ControlBus" title="ControlBus">ControlBus</a></li>
	<li><a href="/confluence/display/CAMEL/Camel+JMX" title="Camel JMX">Camel JMX</a></li>
</ul>

    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/ControlBus+Component">View
Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=30740964&revisedVersion=4&originalVersion=3">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/ControlBus+Component?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message