添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
淡定的打火机  ·  CodeDeploy AppSpec ...·  2 周前    · 
坐怀不乱的莴苣  ·  MQTT disconnects ...·  1 周前    · 
酷酷的柠檬  ·  文章详情·  6 月前    · 
面冷心慈的大象  ·  游戏区-黄油要塞·  11 月前    · 
胆小的创口贴  ·  ARR : définition de ...·  1 年前    · 
低调的葡萄酒  ·  Get Win32_DiskDrive ...·  1 年前    · 

AWS Simple Queue Service (SQS)

Since Camel 3.1

Both producer and consumer are supported

The AWS2 SQS component supports sending and receiving messages to Amazon’s SQS service.

Prerequisites

You must have a valid Amazon Web Services developer account, and be signed up to use Amazon SQS. More information is available at Amazon SQS .

Configuring Options

Camel components are configured on two separate levels:

  • component level

  • endpoint level

Configuring Endpoint Options

You usually spend more time setting up endpoints because they have many options. These options help you customize what you want the endpoint to do. The options are also categorized into whether the endpoint is used as a consumer ( from ), as a producer ( to ), or both.

A good practice when configuring options is to use Property Placeholders .

Property placeholders provide a few benefits:

  • They help prevent using hardcoded urls, port numbers, sensitive information, and other settings.

  • They allow externalizing the configuration from the code.

  • They help the code to become more flexible and reusable.

The following two sections list all the options, firstly for the component followed by the endpoint.

Component Options

The AWS Simple Queue Service (SQS) component supports 52 options, which are listed below.

Name Description Default Type

amazonAWSHost (common)

The hostname of the Amazon AWS cloud.

amazonaws.com

String

autoCreateQueue (common)

Setting the auto-creation of the queue.

false

boolean

configuration (common)

The AWS SQS default configuration.

Sqs2Configuration

overrideEndpoint (common)

Set the need for overriding the endpoint. This option needs to be used in combination with the uriEndpointOverride option.

false

boolean

protocol (common)

The underlying protocol used to communicate with SQS.

https

String

queueOwnerAWSAccountId (common)

Specify the queue owner aws account id when you need to connect the queue with a different account owner.

String

region (common)

The region in which SQS client needs to work. When using this parameter, the configuration will expect the lowercase name of the region (for example, ap-east-1) You’ll need to use the name Region.EU_WEST_1.id().

Enum values:

  • ap-south-2

  • ap-south-1

  • eu-south-1

  • eu-south-2

  • us-gov-east-1

  • me-central-1

  • il-central-1

  • ca-central-1

  • eu-central-1

  • us-iso-west-1

  • eu-central-2

  • eu-isoe-west-1

  • us-west-1

  • us-west-2

  • af-south-1

  • eu-north-1

  • eu-west-3

  • eu-west-2

  • eu-west-1

  • ap-northeast-3

  • ap-northeast-2

  • ap-northeast-1

  • me-south-1

  • sa-east-1

  • ap-east-1

  • cn-north-1

  • ca-west-1

  • us-gov-west-1

  • ap-southeast-1

  • ap-southeast-2

  • us-iso-east-1

  • ap-southeast-3

  • ap-southeast-4

  • us-east-1

  • us-east-2

  • cn-northwest-1

  • us-isob-east-1

  • aws-global

  • aws-cn-global

  • aws-us-gov-global

  • aws-iso-global

  • aws-iso-b-global

String

uriEndpointOverride (common)

Set the overriding uri endpoint. This option needs to be used in combination with overrideEndpoint option.

String

attributeNames (consumer)

A list of attribute names to receive when consuming. Multiple names can be separated by comma.

String

bridgeErrorHandler (consumer)

Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions (if possible) occurred while the Camel consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. Important: This is only possible if the 3rd party component allows Camel to be alerted if an exception was thrown. Some components handle this internally only, and therefore bridgeErrorHandler is not possible. In other situations we may improve the Camel component to hook into the 3rd party component and make this possible for future releases. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored.

false

boolean

concurrentConsumers (consumer)

Allows you to use multiple threads to poll the sqs queue to increase throughput.

1

int

concurrentRequestLimit (consumer)

The maximum number of concurrent receive request send to AWS in single consumer polling.

50

int

defaultVisibilityTimeout (consumer)

The default visibility timeout (in seconds).

Integer

deleteAfterRead (consumer)

Delete message from SQS after it has been read.

true

boolean

deleteIfFiltered (consumer)

Whether to send the DeleteMessage to the SQS queue if the exchange has property with key Sqs2Constants#SQS_DELETE_FILTERED (CamelAwsSqsDeleteFiltered) set to true.

true

boolean

extendMessageVisibility (consumer)

If enabled, then a scheduled background task will keep extending the message visibility on SQS. This is needed if it takes a long time to process the message. If set to true defaultVisibilityTimeout must be set. See details at Amazon docs.

false

boolean

kmsDataKeyReusePeriodSeconds (consumer)

The length of time, in seconds, for which Amazon SQS can reuse a data key to encrypt or decrypt messages before calling AWS KMS again. An integer representing seconds, between 60 seconds (1 minute) and 86,400 seconds (24 hours). Default: 300 (5 minutes).

Integer

kmsMasterKeyId (consumer)

The ID of an AWS-managed customer master key (CMK) for Amazon SQS or a custom CMK.

String

messageAttributeNames (consumer)

A list of message attribute names to receive when consuming. Multiple names can be separated by comma.

String

serverSideEncryptionEnabled (consumer)

Define if Server Side Encryption is enabled or not on the queue.

false

boolean

sortAttributeName (consumer)

The name of the message attribute used for sorting the messages. When specified, the messages polled by the consumer will be sorted by this attribute. This configuration may be of importance when you configure maxMessagesPerPoll parameter exceeding 10. In such cases, the messages will be fetched concurrently so the ordering is not guaranteed.

String

visibilityTimeout (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.SetQueueAttributesRequest. This only makes sense if it’s different from defaultVisibilityTimeout. It changes the queue visibility timeout attribute permanently.

Integer

waitTimeSeconds (consumer)

Duration in seconds (0 to 20) that the ReceiveMessage action call will wait until a message is in the queue to include in the response.

Integer

batchSeparator (producer)

Set the separator when passing a String to send batch message operation.

,

String

delaySeconds (producer)

Delay sending messages for a number of seconds.

Integer

lazyStartProducer (producer)

Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing.

false

boolean

messageDeduplicationIdStrategy (producer)

Only for FIFO queues. Strategy for setting the messageDeduplicationId on the message. It can be one of the following options: useExchangeId, useContentBasedDeduplication. For the useContentBasedDeduplication option, no messageDeduplicationId will be set on the message.

Enum values:

  • useExchangeId

  • useContentBasedDeduplication

useExchangeId

String

messageGroupIdStrategy (producer)

Only for FIFO queues. Strategy for setting the messageGroupId on the message. It can be one of the following options: useConstant, useExchangeId, usePropertyValue. For the usePropertyValue option, the value of property CamelAwsMessageGroupId will be used.

Enum values:

  • useConstant

  • useExchangeId

  • usePropertyValue

String

messageHeaderExceededLimit (producer)

What to do if sending to AWS SQS has more messages than AWS allows (currently only maximum 10 message headers are allowed). WARN will log a WARN about the limit is for each additional header, so the message can be sent to AWS. WARN_ONCE will only log one time a WARN about the limit is hit, and drop additional headers, so the message can be sent to AWS. IGNORE will ignore (no logging) and drop additional headers, so the message can be sent to AWS. FAIL will cause an exception to be thrown and the message is not sent to AWS.

Enum values:

  • WARN

  • WARN_ONCE

  • IGNORE

  • FAIL

WARN

String

operation (producer)

The operation to do in case the user don’t want to send only a message.

Enum values:

  • sendBatchMessage

  • deleteMessage

  • listQueues

  • purgeQueue

  • deleteQueue

Sqs2Operations

amazonSQSClient (advanced)

Autowired To use the AmazonSQS client.

SqsClient

autowiredEnabled (advanced)

Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc.

true

boolean

delayQueue (advanced)

Define if you want to apply delaySeconds option to the queue or on single messages.

false

boolean

healthCheckConsumerEnabled (health)

Used for enabling or disabling all consumer based health checks from this component.

true

boolean

healthCheckProducerEnabled (health)

Used for enabling or disabling all producer based health checks from this component. Notice: Camel has by default disabled all producer based health-checks. You can turn on producer checks globally by setting camel.health.producersEnabled=true.

true

boolean

proxyHost (proxy)

To define a proxy host when instantiating the SQS client.

String

proxyPort (proxy)

To define a proxy port when instantiating the SQS client.

Integer

proxyProtocol (proxy)

To define a proxy protocol when instantiating the SQS client.

Enum values:

  • HTTP

  • HTTPS

HTTPS

Protocol

maximumMessageSize (queue)

The maximumMessageSize (in bytes) an SQS message can contain for this queue.

Integer

messageRetentionPeriod (queue)

The messageRetentionPeriod (in seconds) a message will be retained by SQS for this queue.

Integer

policy (queue)

The policy for this queue. It can be loaded by default from classpath, but you can prefix with classpath:, file:, or http: to load the resource from different systems.

String

queueUrl (queue)

To define the queueUrl explicitly. All other parameters, which would influence the queueUrl, are ignored. This parameter is intended to be used to connect to a mock implementation of SQS, for testing purposes.

String

receiveMessageWaitTimeSeconds (queue)

If you do not specify WaitTimeSeconds in the request, the queue attribute ReceiveMessageWaitTimeSeconds is used to determine how long to wait.

Integer

redrivePolicy (queue)

Specify the policy that send message to DeadLetter queue. See detail at Amazon docs.

String

accessKey (security)

Amazon AWS Access Key.

String

profileCredentialsName (security)

If using a profile credentials provider, this parameter will set the profile name.

String

secretKey (security)

Amazon AWS Secret Key.

String

sessionToken (security)

Amazon AWS Session Token used when the user needs to assume an IAM role.

String

trustAllCertificates (security)

If we want to trust all certificates in case of overriding the endpoint.

false

boolean

useDefaultCredentialsProvider (security)

Set whether the SQS client should expect to load credentials on an AWS infra instance or to expect static credentials to be passed in.

false

boolean

useProfileCredentialsProvider (security)

Set whether the SQS client should expect to load credentials through a profile credentials provider.

false

boolean

useSessionCredentials (security)

Set whether the SQS client should expect to use Session Credentials. This is useful in a situation in which the user needs to assume an IAM role for doing operations in SQS.

false

boolean

Endpoint Options

The AWS Simple Queue Service (SQS) endpoint is configured using URI syntax:

aws2-sqs:queueNameOrArn

With the following path and query parameters:

Query Parameters (68 parameters)

Name Description Default Type

amazonAWSHost (common)

The hostname of the Amazon AWS cloud.

amazonaws.com

String

autoCreateQueue (common)

Setting the auto-creation of the queue.

false

boolean

headerFilterStrategy (common)

To use a custom HeaderFilterStrategy to map headers to/from Camel.

HeaderFilterStrategy

overrideEndpoint (common)

Set the need for overriding the endpoint. This option needs to be used in combination with the uriEndpointOverride option.

false

boolean

protocol (common)

The underlying protocol used to communicate with SQS.

https

String

queueOwnerAWSAccountId (common)

Specify the queue owner aws account id when you need to connect the queue with a different account owner.

String

region (common)

The region in which SQS client needs to work. When using this parameter, the configuration will expect the lowercase name of the region (for example, ap-east-1) You’ll need to use the name Region.EU_WEST_1.id().

Enum values:

  • ap-south-2

  • ap-south-1

  • eu-south-1

  • eu-south-2

  • us-gov-east-1

  • me-central-1

  • il-central-1

  • ca-central-1

  • eu-central-1

  • us-iso-west-1

  • eu-central-2

  • eu-isoe-west-1

  • us-west-1

  • us-west-2

  • af-south-1

  • eu-north-1

  • eu-west-3

  • eu-west-2

  • eu-west-1

  • ap-northeast-3

  • ap-northeast-2

  • ap-northeast-1

  • me-south-1

  • sa-east-1

  • ap-east-1

  • cn-north-1

  • ca-west-1

  • us-gov-west-1

  • ap-southeast-1

  • ap-southeast-2

  • us-iso-east-1

  • ap-southeast-3

  • ap-southeast-4

  • us-east-1

  • us-east-2

  • cn-northwest-1

  • us-isob-east-1

  • aws-global

  • aws-cn-global

  • aws-us-gov-global

  • aws-iso-global

  • aws-iso-b-global

String

uriEndpointOverride (common)

Set the overriding uri endpoint. This option needs to be used in combination with overrideEndpoint option.

String

attributeNames (consumer)

A list of attribute names to receive when consuming. Multiple names can be separated by comma.

String

concurrentConsumers (consumer)

Allows you to use multiple threads to poll the sqs queue to increase throughput.

1

int

concurrentRequestLimit (consumer)

The maximum number of concurrent receive request send to AWS in single consumer polling.

50

int

defaultVisibilityTimeout (consumer)

The default visibility timeout (in seconds).

Integer

deleteAfterRead (consumer)

Delete message from SQS after it has been read.

true

boolean

deleteIfFiltered (consumer)

Whether to send the DeleteMessage to the SQS queue if the exchange has property with key Sqs2Constants#SQS_DELETE_FILTERED (CamelAwsSqsDeleteFiltered) set to true.

true

boolean

extendMessageVisibility (consumer)

If enabled, then a scheduled background task will keep extending the message visibility on SQS. This is needed if it takes a long time to process the message. If set to true defaultVisibilityTimeout must be set. See details at Amazon docs.

false

boolean

kmsDataKeyReusePeriodSeconds (consumer)

The length of time, in seconds, for which Amazon SQS can reuse a data key to encrypt or decrypt messages before calling AWS KMS again. An integer representing seconds, between 60 seconds (1 minute) and 86,400 seconds (24 hours). Default: 300 (5 minutes).

Integer

kmsMasterKeyId (consumer)

The ID of an AWS-managed customer master key (CMK) for Amazon SQS or a custom CMK.

String

maxMessagesPerPoll (consumer)

Gets the maximum number of messages as a limit to poll at each polling. Is default unlimited, but use 0 or negative number to disable it as unlimited.

int

messageAttributeNames (consumer)

A list of message attribute names to receive when consuming. Multiple names can be separated by comma.

String

sendEmptyMessageWhenIdle (consumer)

If the polling consumer did not poll any files, you can enable this option to send an empty message (no body) instead.

false

boolean

serverSideEncryptionEnabled (consumer)

Define if Server Side Encryption is enabled or not on the queue.

false

boolean

sortAttributeName (consumer)

The name of the message attribute used for sorting the messages. When specified, the messages polled by the consumer will be sorted by this attribute. This configuration may be of importance when you configure maxMessagesPerPoll parameter exceeding 10. In such cases, the messages will be fetched concurrently so the ordering is not guaranteed.

String

visibilityTimeout (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.SetQueueAttributesRequest. This only makes sense if it’s different from defaultVisibilityTimeout. It changes the queue visibility timeout attribute permanently.

Integer

waitTimeSeconds (consumer)

Duration in seconds (0 to 20) that the ReceiveMessage action call will wait until a message is in the queue to include in the response.

Integer

bridgeErrorHandler (consumer (advanced))

Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions (if possible) occurred while the Camel consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. Important: This is only possible if the 3rd party component allows Camel to be alerted if an exception was thrown. Some components handle this internally only, and therefore bridgeErrorHandler is not possible. In other situations we may improve the Camel component to hook into the 3rd party component and make this possible for future releases. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored.

false

boolean

exceptionHandler (consumer (advanced))

To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored.

ExceptionHandler

exchangePattern (consumer (advanced))

Sets the exchange pattern when the consumer creates an exchange.

Enum values:

  • InOnly

  • InOut

ExchangePattern

pollStrategy (consumer (advanced))

A pluggable org.apache.camel.PollingConsumerPollingStrategy allowing you to provide your custom implementation to control error handling usually occurred during the poll operation before an Exchange have been created and being routed in Camel.

PollingConsumerPollStrategy

batchSeparator (producer)

Set the separator when passing a String to send batch message operation.

,

String

delaySeconds (producer)

Delay sending messages for a number of seconds.

Integer

messageDeduplicationIdStrategy (producer)

Only for FIFO queues. Strategy for setting the messageDeduplicationId on the message. It can be one of the following options: useExchangeId, useContentBasedDeduplication. For the useContentBasedDeduplication option, no messageDeduplicationId will be set on the message.

Enum values:

  • useExchangeId

  • useContentBasedDeduplication

useExchangeId

String

messageGroupIdStrategy (producer)

Only for FIFO queues. Strategy for setting the messageGroupId on the message. It can be one of the following options: useConstant, useExchangeId, usePropertyValue. For the usePropertyValue option, the value of property CamelAwsMessageGroupId will be used.

Enum values:

  • useConstant

  • useExchangeId

  • usePropertyValue

String

messageHeaderExceededLimit (producer)

What to do if sending to AWS SQS has more messages than AWS allows (currently only maximum 10 message headers are allowed). WARN will log a WARN about the limit is for each additional header, so the message can be sent to AWS. WARN_ONCE will only log one time a WARN about the limit is hit, and drop additional headers, so the message can be sent to AWS. IGNORE will ignore (no logging) and drop additional headers, so the message can be sent to AWS. FAIL will cause an exception to be thrown and the message is not sent to AWS.

Enum values:

  • WARN

  • WARN_ONCE

  • IGNORE

  • FAIL

WARN

String

operation (producer)

The operation to do in case the user don’t want to send only a message.

Enum values:

  • sendBatchMessage

  • deleteMessage

  • listQueues

  • purgeQueue

  • deleteQueue

Sqs2Operations

lazyStartProducer (producer (advanced))

Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing.

false

boolean

amazonSQSClient (advanced)

Autowired To use the AmazonSQS client.

SqsClient

delayQueue (advanced)

Define if you want to apply delaySeconds option to the queue or on single messages.

false

boolean

proxyHost (proxy)

To define a proxy host when instantiating the SQS client.

String

proxyPort (proxy)

To define a proxy port when instantiating the SQS client.

Integer

proxyProtocol (proxy)

To define a proxy protocol when instantiating the SQS client.

Enum values:

  • HTTP

  • HTTPS

HTTPS

Protocol

maximumMessageSize (queue)

The maximumMessageSize (in bytes) an SQS message can contain for this queue.

Integer

messageRetentionPeriod (queue)

The messageRetentionPeriod (in seconds) a message will be retained by SQS for this queue.

Integer

policy (queue)

The policy for this queue. It can be loaded by default from classpath, but you can prefix with classpath:, file:, or http: to load the resource from different systems.

String

queueUrl (queue)

To define the queueUrl explicitly. All other parameters, which would influence the queueUrl, are ignored. This parameter is intended to be used to connect to a mock implementation of SQS, for testing purposes.

String

receiveMessageWaitTimeSeconds (queue)

If you do not specify WaitTimeSeconds in the request, the queue attribute ReceiveMessageWaitTimeSeconds is used to determine how long to wait.

Integer

redrivePolicy (queue)

Specify the policy that send message to DeadLetter queue. See detail at Amazon docs.

String

backoffErrorThreshold (scheduler)

The number of subsequent error polls (failed due some error) that should happen before the backoffMultipler should kick-in.

int

backoffIdleThreshold (scheduler)

The number of subsequent idle polls that should happen before the backoffMultipler should kick-in.

int

backoffMultiplier (scheduler)

To let the scheduled polling consumer backoff if there has been a number of subsequent idles/errors in a row. The multiplier is then the number of polls that will be skipped before the next actual attempt is happening again. When this option is in use then backoffIdleThreshold and/or backoffErrorThreshold must also be configured.

int

delay (scheduler)

Milliseconds before the next poll.

500

long

greedy (scheduler)

If greedy is enabled, then the ScheduledPollConsumer will run immediately again, if the previous run polled 1 or more messages.

false

boolean

initialDelay (scheduler)

Milliseconds before the first poll starts.

1000

long

repeatCount (scheduler)

Specifies a maximum limit of number of fires. So if you set it to 1, the scheduler will only fire once. If you set it to 5, it will only fire five times. A value of zero or negative means fire forever.

0

long

runLoggingLevel (scheduler)

The consumer logs a start/complete log line when it polls. This option allows you to configure the logging level for that.

Enum values:

  • TRACE

  • DEBUG

  • INFO

  • WARN

  • ERROR

  • OFF

TRACE

LoggingLevel

scheduledExecutorService (scheduler)

Allows for configuring a custom/shared thread pool to use for the consumer. By default each consumer has its own single threaded thread pool.

ScheduledExecutorService

scheduler (scheduler)

To use a cron scheduler from either camel-spring or camel-quartz component. Use value spring or quartz for built in scheduler.

none

Object

schedulerProperties (scheduler)

To configure additional properties when using a custom scheduler or any of the Quartz, Spring based scheduler.

Map

startScheduler (scheduler)

Whether the scheduler should be auto started.

true

boolean

timeUnit (scheduler)

Time unit for initialDelay and delay options.

Enum values:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

MILLISECONDS

TimeUnit

useFixedDelay (scheduler)

Controls if fixed delay or fixed rate is used. See ScheduledExecutorService in JDK for details.

true

boolean

accessKey (security)

Amazon AWS Access Key.

String

profileCredentialsName (security)

If using a profile credentials provider, this parameter will set the profile name.

String

secretKey (security)

Amazon AWS Secret Key.

String

sessionToken (security)

Amazon AWS Session Token used when the user needs to assume an IAM role.

String

trustAllCertificates (security)

If we want to trust all certificates in case of overriding the endpoint.

false

boolean

useDefaultCredentialsProvider (security)

Set whether the SQS client should expect to load credentials on an AWS infra instance or to expect static credentials to be passed in.

false

boolean

useProfileCredentialsProvider (security)

Set whether the SQS client should expect to load credentials through a profile credentials provider.

false

boolean

useSessionCredentials (security)

Set whether the SQS client should expect to use Session Credentials. This is useful in a situation in which the user needs to assume an IAM role for doing operations in SQS.

false

boolean

Required SQS component options

Examples

DelayQueue VS Delay for Single message

  • For standard queues, the per-queue delay setting is not retroactively—changing the setting doesn’t affect the delay of messages already in the queue.

  • For FIFO queues, the per-queue delay setting is retroactively—changing the setting affects the delay of messages already in the queue.

as stated in the official documentation. If you want to specify a delay on single messages, you can ignore the delayQueue option, while you can set this option to true if you need to add a fixed delay to all messages enqueued.