camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Camel > How do I configure endpoints
Date Thu, 14 Jun 2012 19:47: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/How+do+I+configure+endpoints">How
do I configure endpoints</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~bvahdat">Babak
Vahdat</a>
    </h4>
        <br/>
                         <h4>Changes (1)</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" > <br>{code} <br></td></tr>
            <tr><td class="diff-changed-lines" >SomeEndpoint endpoint = <span
class="diff-changed-words"><span class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;">(SomeEndpoint)
</span>camelContext.getEndpoint(&quot;someURI&quot;<span class="diff-added-chars"style="background-color:
#dfd;">, SomeEndpoint.class</span>);</span> <br></td></tr>
            <tr><td class="diff-unchanged" >endpoint.setSomething(&quot;aValue&quot;);
<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="HowdoIconfigureendpoints-HowdoIconfigureendpoints%3F"></a>How
do I configure endpoints?</h2>

<p>There are a few different approaches to configuring components and endpoints. </p>

<h3><a name="HowdoIconfigureendpoints-UsingJavaCode"></a>Using Java Code</h3>

<p>You can explicitly configure a <a href="/confluence/display/CAMEL/Component" title="Component">Component</a>
using Java code as shown in this <a href="/confluence/display/CAMEL/Walk+through+an+Example"
title="Walk through an Example">example</a> </p>

<p>Or you can explicitly get hold of an <a href="/confluence/display/CAMEL/Endpoint"
title="Endpoint">Endpoint</a> and configure it using Java code as shown in the <a
href="/confluence/display/CAMEL/Mock" title="Mock">Mock endpoint examples</a>.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
SomeEndpoint endpoint = camelContext.getEndpoint(<span class="code-quote">"someURI"</span>,
SomeEndpoint.class);
endpoint.setSomething(<span class="code-quote">"aValue"</span>);
</pre>
</div></div>

<h3><a name="HowdoIconfigureendpoints-UsingGuice"></a>Using Guice</h3>

<p>You can also use <a href="/confluence/display/CAMEL/Guice" title="Guice">Guice</a>
as the dependency injection framework. For example see the <a href="/confluence/display/CAMEL/Guice+JMS+Example"
title="Guice JMS Example">Guice JMS Example</a></p>

<h3><a name="HowdoIconfigureendpoints-UsingSpringXML"></a>Using Spring XML</h3>

<p>You can configure your <a href="/confluence/display/CAMEL/Component" title="Component">Component</a>
or <a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a>
instances in your <a href="/confluence/display/CAMEL/Spring" title="Spring">Spring</a>
XML as follows. </p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml"><span class="code-tag">&lt;camelContext id=<span
class="code-quote">"camel"</span> xmlns=<span class="code-quote">"http://camel.apache.org/schema/spring"</span>&gt;</span>
    <span class="code-tag">&lt;jmxAgent id=<span class="code-quote">"agent"</span>
disabled=<span class="code-quote">"true"</span>/&gt;</span>
<span class="code-tag">&lt;/camelContext&gt;</span>

<span class="code-tag">&lt;bean id=<span class="code-quote">"activemq"</span>
class=<span class="code-quote">"org.apache.activemq.camel.component.ActiveMQComponent"</span>&gt;</span>
  <span class="code-tag">&lt;property name=<span class="code-quote">"connectionFactory"</span>&gt;</span>
    <span class="code-tag">&lt;bean class=<span class="code-quote">"org.apache.activemq.ActiveMQConnectionFactory"</span>&gt;</span>
      <span class="code-tag">&lt;property name=<span class="code-quote">"brokerURL"</span>
value=<span class="code-quote">"vm://localhost?broker.persistent=false&amp;amp;broker.useJmx=false"</span>/&gt;</span>
    <span class="code-tag">&lt;/bean&gt;</span>
  <span class="code-tag">&lt;/property&gt;</span>
<span class="code-tag">&lt;/bean&gt;</span>
</pre>
</div></div>

<p>Which allows you to configure a component using some name (activemq in the above
example), then you can refer to the component using <b>activemq:[queue:&#124;topic:]destinationName</b>.
This works by the SpringCamelContext lazily fetching components from the spring context for
the scheme name you use for <a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a>
<a href="/confluence/display/CAMEL/URIs" title="URIs">URIs</a></p>

<h3><a name="HowdoIconfigureendpoints-UsingEndpointURIs"></a>Using Endpoint
URIs</h3>

<p>Another approach is to use the URI syntax. The URI syntax supports the query notation.
So for example with the <a href="/confluence/display/CAMEL/Mail" title="Mail">Mail</a>
component you can configure the password property via the URI</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
pop3:<span class="code-comment">//host:port?password=foo</span>
</pre>
</div></div>

<h4><a name="HowdoIconfigureendpoints-ReferringbeansfromEndpointURIs"></a>Referring
beans from Endpoint URIs </h4>
<p><b>Available as of Camel 2.0</b></p>

<p>When configuring endpoints using URI syntax you can now refer to beans in the <a
href="/confluence/display/CAMEL/Registry" title="Registry">Registry</a> using the
# notation.<br/>
If the parameter value starts with a <tt>#</tt> sign then Camel will lookup in
the <a href="/confluence/display/CAMEL/Registry" title="Registry">Registry</a>
for a bean of the given type. For instance:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
file:<span class="code-comment">//inbox?sorter=#mySpecialFileSorter</span>
</pre>
</div></div>
<p>Will lookup a bean with the id <b>mySpecialFileSorter</b> in the <a
href="/confluence/display/CAMEL/Registry" title="Registry">Registry</a>.</p>

<h2><a name="HowdoIconfigureendpoints-SeeAlso"></a>See Also</h2>

<ul>
	<li><a href="/confluence/display/CAMEL/How+do+I+add+a+component" title="How do I
add a component">How do I add a component</a></li>
	<li><a href="/confluence/display/CAMEL/Spring" title="Spring">Spring</a></li>
	<li><a href="/confluence/display/CAMEL/URIs" title="URIs">URIs</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/How+do+I+configure+endpoints">View
Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=53767&revisedVersion=14&originalVersion=13">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/How+do+I+configure+endpoints?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message