camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Camel > AWS-SQS
Date Sun, 15 May 2011 16:00: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/AWS-SQS">AWS-SQS</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~muellerc">Christian
Mueller</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" >|visibilityTimeout | {{null}} | Shared
| The duration (in seconds) that the received messages are hidden from subsequent retrieve
requests after being retrieved by a ReceiveMessage request to set in the {{com.amazonaws.services.sqs.model.SetQueueAttributesRequest}}.
This only make sense if its different from {{defaultVisibilityTimeout}}. It changes the queue
visibility timeout attribute permanently. | <br>|messageVisibilityTimeout | {{null}}
| Consumer | The duration (in seconds) that the received messages are hidden from subsequent
retrieve requests after being retrieved by a ReceiveMessage request to set in the {{com.amazonaws.services.sqs.model.ReceiveMessageRequest}}.
It does *NOT* change the queue visibility timeout attribute permanently. | <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">|maximumMessageSize
| {{null}} | Shared | The maximumMessageSize (in bytes) an SQS message can contain for this
queue, to set in the {{com.amazonaws.services.sqs.model.SetQueueAttributesRequest}}. | <br>|messageRetentionPeriod
| {{null}} | Shared | The messageRetentionPeriod (in seconds) a message will be retained by
SQS for this queue, to set in the {{com.amazonaws.services.sqs.model.SetQueueAttributesRequest}}.
| <br>|policy | {{null}} | Shared | The policy for this queue to set in the {{com.amazonaws.services.sqs.model.SetQueueAttributesRequest}}.
| <br></td></tr>
            <tr><td class="diff-unchanged" > <br>{info:title=Required SQS
component options} <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h2><a name="AWS-SQS-SQSComponent"></a>SQS Component</h2>
<p><b>Available as of Camel 2.6</b></p>

<p>The sqs component supports sending and receiving messages to <a href="http://aws.amazon.com/sqs"
class="external-link" rel="nofollow">Amazon's SQS</a> service.</p>

<div class='panelMacro'><table class='infoMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/information.gif" width="16"
height="16" align="absmiddle" alt="" border="0"></td><td><b>Prerequisites</b><br
/>You must have a valid Amazon Web Services developer account, and be signed up to use
Amazon SQS. More information are available at <a href="http://aws.amazon.com/sqs" class="external-link"
rel="nofollow">Amazon SQS</a>.</td></tr></table></div>

<h3><a name="AWS-SQS-URIFormat"></a>URI Format</h3>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
aws-sqs:<span class="code-comment">//queue-name[?options]</span>
</pre>
</div></div>
<p>The queue will be created if they don't already exists.<br/>
You can append query options to the URI in the following format, ?options=value&amp;option2=value&amp;...</p>

<h3><a name="AWS-SQS-URIOptions"></a>URI Options</h3>
<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Default Value </th>
<th class='confluenceTh'> Context </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'>amazonSQSClient </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> Shared </td>
<td class='confluenceTd'> Reference to a <tt>com.amazonaws.services.sqs.AmazonSQSClient</tt>
in the <a href="/confluence/display/CAMEL/Registry" title="Registry">Registry</a>.
</td>
</tr>
<tr>
<td class='confluenceTd'>accessKey </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> Shared </td>
<td class='confluenceTd'> Amazon AWS Access Key </td>
</tr>
<tr>
<td class='confluenceTd'>secretKey </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> Shared </td>
<td class='confluenceTd'> Amazon AWS Secret Key </td>
</tr>
<tr>
<td class='confluenceTd'>amazonSQSEndpoint </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> Shared </td>
<td class='confluenceTd'> The region with which the AWS-SQS client wants to work with.
</td>
</tr>
<tr>
<td class='confluenceTd'>attributeNames </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> Consumer </td>
<td class='confluenceTd'> A list of attributes to set in the <tt>com.amazonaws.services.sqs.model.ReceiveMessageRequest</tt>.
</td>
</tr>
<tr>
<td class='confluenceTd'>defaultVisibilityTimeout </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> Shared </td>
<td class='confluenceTd'> The visibility timeout (in seconds) to set in the <tt>com.amazonaws.services.sqs.model.CreateQueueRequest</tt>.
</td>
</tr>
<tr>
<td class='confluenceTd'>deleteAfterRead </td>
<td class='confluenceTd'> <tt>true</tt> </td>
<td class='confluenceTd'> Consumer </td>
<td class='confluenceTd'> Delete message from SQS after it has been read </td>
</tr>
<tr>
<td class='confluenceTd'>maxMessagesPerPoll</td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> Consumer </td>
<td class='confluenceTd'> The maximum number of messages which can be received in one
poll to set in the <tt>com.amazonaws.services.sqs.model.ReceiveMessageRequest</tt>.
</td>
</tr>
<tr>
<td class='confluenceTd'>visibilityTimeout </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> Shared </td>
<td class='confluenceTd'> The duration (in seconds) that the received messages are hidden
from subsequent retrieve requests after being retrieved by a ReceiveMessage request to set
in the <tt>com.amazonaws.services.sqs.model.SetQueueAttributesRequest</tt>. This
only make sense if its different from <tt>defaultVisibilityTimeout</tt>. It changes
the queue visibility timeout attribute permanently. </td>
</tr>
<tr>
<td class='confluenceTd'>messageVisibilityTimeout </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> Consumer </td>
<td class='confluenceTd'> The duration (in seconds) that the received messages are hidden
from subsequent retrieve requests after being retrieved by a ReceiveMessage request to set
in the <tt>com.amazonaws.services.sqs.model.ReceiveMessageRequest</tt>. It does
<b>NOT</b> change the queue visibility timeout attribute permanently. </td>
</tr>
<tr>
<td class='confluenceTd'>maximumMessageSize </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> Shared </td>
<td class='confluenceTd'> The maximumMessageSize (in bytes) an SQS message can contain
for this queue, to set in the <tt>com.amazonaws.services.sqs.model.SetQueueAttributesRequest</tt>.
</td>
</tr>
<tr>
<td class='confluenceTd'>messageRetentionPeriod </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> Shared </td>
<td class='confluenceTd'> The messageRetentionPeriod (in seconds) a message will be
retained by SQS for this queue, to set in the <tt>com.amazonaws.services.sqs.model.SetQueueAttributesRequest</tt>.
</td>
</tr>
<tr>
<td class='confluenceTd'>policy </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> Shared </td>
<td class='confluenceTd'> The policy for this queue to set in the <tt>com.amazonaws.services.sqs.model.SetQueueAttributesRequest</tt>.
</td>
</tr>
</tbody></table>
</div>


<div class='panelMacro'><table class='infoMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/information.gif" width="16"
height="16" align="absmiddle" alt="" border="0"></td><td><b>Required
SQS component options</b><br />You have to provide the amazonSQSClient in the
<a href="/confluence/display/CAMEL/Registry" title="Registry">Registry</a> or
your accessKey and secretKey to access the <a href="http://aws.amazon.com/sqs" class="external-link"
rel="nofollow">Amazon's SQS</a>.</td></tr></table></div>

<h3><a name="AWS-SQS-BatchConsumer"></a>Batch Consumer</h3>
<p>This component implements the <a href="/confluence/display/CAMEL/Batch+Consumer"
title="Batch Consumer">Batch Consumer</a>. </p>

<p>This allows you for instance to know how many messages exists in this batch and for
instance let the <a href="/confluence/display/CAMEL/Aggregator" title="Aggregator">Aggregator</a>
aggregate this number of messages.</p>

<h3><a name="AWS-SQS-Usage"></a>Usage</h3>
<h4><a name="AWS-SQS-MessageheaderssetbytheSQSproducer"></a>Message headers
set by the SQS producer</h4>
<div class="confluenceTableSmall"><div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Header </th>
<th class='confluenceTh'> Type </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelAwsSqsMD5OfBody</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> The MD5 checksum of the Amazon SQS message. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelAwsSqsMessageId</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> The Amazon SQS message ID. </td>
</tr>
</tbody></table>
</div>
</div>

<h4><a name="AWS-SQS-MessageheaderssetbytheSQSconsumer"></a>Message headers
set by the SQS consumer</h4>
<div class="confluenceTableSmall"><div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Header </th>
<th class='confluenceTh'> Type </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelAwsSqsMD5OfBody</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> The MD5 checksum of the Amazon SQS message. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelAwsSqsMessageId</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> The Amazon SQS message ID. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelAwsSqsReceiptHandle</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'>  The Amazon SQS message receipt handle. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelAwsSqsAttributes</tt> </td>
<td class='confluenceTd'> <tt>Map&lt;String, String&gt;</tt> </td>
<td class='confluenceTd'> The Amazon SQS message attributes. </td>
</tr>
</tbody></table>
</div>
</div>

<h4><a name="AWS-SQS-AdvancedAmazonSQSClientconfiguration"></a>Advanced
AmazonSQSClient configuration</h4>
<p>If your Camel Application is running behind a firewall or if you need to have more
control over the AmazonSQSClient configuration, you can create your own instance:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
AWSCredentials awsCredentials = <span class="code-keyword">new</span> BasicAWSCredentials(<span
class="code-quote">"myAccessKey"</span>, <span class="code-quote">"mySecretKey"</span>);

ClientConfiguration clientConfiguration = <span class="code-keyword">new</span>
ClientConfiguration();
clientConfiguration.setProxyHost(<span class="code-quote">"http:<span class="code-comment">//myProxyHost"</span>);
</span>clientConfiguration.setProxyPort(8080);

AmazonSQSClient client = <span class="code-keyword">new</span> AmazonSQSClient(awsCredentials,
clientConfiguration);
</pre>
</div></div>

<p>and refer to it in your Camel aws-sqs component configuration:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"aws-sqs:<span class="code-comment">//MyQueue?amazonSQSClient=#amazonSQSClient&amp;delay=5000&amp;maxMessagesPerPoll=5"</span>)
</span>.to(<span class="code-quote">"mock:result"</span>);
</pre>
</div></div>

<h3><a name="AWS-SQS-Dependencies"></a>Dependencies</h3>
<p>Maven users will need to add the following dependency to their pom.xml.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader"
style="border-bottom-width: 1px;"><b>pom.xml</b></div><div class="codeContent
panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;dependency&gt;</span>
    <span class="code-tag">&lt;groupId&gt;</span>org.apache.camel<span
class="code-tag">&lt;/groupId&gt;</span>
    <span class="code-tag">&lt;artifactId&gt;</span>camel-aws<span
class="code-tag">&lt;/artifactId&gt;</span>
    <span class="code-tag">&lt;version&gt;</span>${camel-version}<span
class="code-tag">&lt;/version&gt;</span>
<span class="code-tag">&lt;/dependency&gt;</span>
</pre>
</div></div>

<p>where <tt>${camel-version</tt>} must be replaced by the actual version
of Camel (2.6 or higher).</p>

<h3><a name="AWS-SQS-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/AWS" title="AWS">AWS Component</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/AWS-SQS">View Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=24838327&revisedVersion=14&originalVersion=13">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/AWS-SQS?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message