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:37: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 (2)</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" >*Available as of Camel 2.11* <br>
<br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">The
*controlbus:* 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 *same* camel context. <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">The
*controlbus:* component provides easy management of Camel applications based on the [Control
Bus|ControlBus] EIP pattern. <br>For example by sending a message to an [Endpoint] you
can control the lifecycle of routes, or gather performance statistics. <br></td></tr>
            <tr><td class="diff-unchanged" > <br>{code} <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 easy management of Camel applications
based on the <a href="/confluence/display/CAMEL/ControlBus" title="ControlBus">Control
Bus</a> EIP pattern.<br/>
For example by sending a message to an <a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a>
you can control the lifecycle of routes, or gather performance statistics.</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>
EIP</li>
	<li><a href="/confluence/display/CAMEL/JMX" title="JMX">JMX</a> Component</li>
	<li>Using <a href="/confluence/display/CAMEL/Camel+JMX" title="Camel JMX">JMX</a>
with Camel</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=6&originalVersion=5">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