THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
Wiki Markup |
---|
h2. SQS Component *Available as of Camel 2.6* The sqs component supports sending and receiving messages to [Amazon's SQS|http://aws.amazon.com/sqs] service. {info:title=Prerequisites} You must have a valid Amazon Web Services developer account, and be signed up to use Amazon SQS. More information are available at [Amazon SQS|http://aws.amazon.com/sqs]. {info} h3. URI Format {code} aws-sqs://queue-name {code} h3. URI Options || Name || Default Value || Context || Description || |amazonSQSClient | {{null}} | Shared | Reference to a com.amazonaws.services.sqs.AmazonSQSClient in the [Registry]. | |accessKey | {{null}} | Shared | Amazon AWS Access Key | |secretKey | {{null}} | Shared | Amazon AWS Secret Key | |attributeNames | {{null}} | Consumer | A list of attributes to set in the {{com.amazonaws.services.sqs.model.ReceiveMessageRequest}}. | |defaultVisibilityTimeout | {{null}} | Shared | The visibility timeout (in seconds) to set in the {{com.amazonaws.services.sqs.model.CreateQueueRequest}}. | |deleteAfterRead | {{true}} | Consumer | Delete message from SQS after it has been read | |maxMessagesPerPoll| {{null}} | Consumer | The maximum number of messages which can be received in one poll to set in the {{com.amazonaws.services.sqs.model.ReceiveMessageRequest}}. | |visibilityTimeout | {{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}}. | {info:title=Required SQS component options} You have to provide the amazonSQSClient in the [Registry] or your accessKey and secretKey to access the [Amazon's SQS|http://aws.amazon.com/sqs]. {info} h3. Usage h3. Batch Consumer This component implements the [Batch Consumer]. h3. Usage h4. Message headers set by the producer {div:class=confluenceTableSmall} || Header || Type || Description || | {{CamelAwsSqsMD5OfBody}} | {{String}} | The MD5 checksum of the Amazon SQS message. | | {{CamelAwsSqsMessageId}} | {{String}} | The Amazon SQS message ID. | {div} h4. Message headers set by the consumer {div:class=confluenceTableSmall} || Header || Type || Description || | {{CamelAwsSqsMD5OfBody}} | {{String}} | The MD5 checksum of the Amazon SQS message. | | {{CamelAwsSqsMessageId}} | {{String}} | The Amazon SQS message ID. | | {{CamelAwsSqsReceiptHandle}} | {{String}} | The Amazon SQS message receipt handle. | | {{CamelAwsSqsAttributes}} | {{Map<String, String>}} | The Amazon SQS message attributes. | {div} h4. Exchange Properties, sqsset by the consumer only As the sqs consumer is {{BatchConsumer}} it supports batching the messages it polls. By batching it means that Camel will add some properties to the [Exchange] so you know the number of messages polled the current index in that order. {div:class=confluenceTableSmall} || Property || Description || | {{CamelBatchSize}} | The total number of messages that was polled in this batch. | | {{CamelBatchIndex}} | The current index of the batch. Starts from 0. | | {{CamelBatchComplete}} | A {{boolean}} value indicating the last [Exchange] in the batch. Is only {{true}} for the last entry. | | {{CamelSqsAttributes}} | The returned attribute {{java.util.Map}}. | | {{CamelSqsReceiptHandle}} | A reference to so that method calls can be chained together (e.g. the delete request after the message is consumed). | {div} This allows you for instance to know how many messages exists in this batch and for instance let the [Aggregator] aggregate this number of messages. h4. Advanced AmazonSQSClient configuration 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: {code} AWSCredentials awsCredentials = new BasicAWSCredentials("myAccessKey", "mySecretKey"); ClientConfiguration clientConfiguration = new ClientConfiguration(); clientConfiguration.setProxyHost("http://myProxyHost"); clientConfiguration.setProxyPort(8080); AmazonSQSClient client = new AmazonSQSClient(awsCredentials, clientConfiguration); {code} and refer to it in your Camel aws-sqs component configuration: {code} from("aws-sqs://MyQueue?amazonSQSClient=#amazonSQSClient&delay=5000&maxMessagesPerPoll=5") .to("mock:result"); {code} h3. Dependencies Maven users will need to add the following dependency to their pom.xml. {code:xml|title=pom.xml} <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-aws</artifactId> <version>${camel-version}</version> </dependency> {code} where {{$\{camel-version\}}} must be replaced by the actual version of Camel (2.6 or higher). {include:Endpoint See Also} - [AWS Component|aws] |