jakubmalek commented on code in PR #14926:
URL: https://github.com/apache/camel/pull/14926#discussion_r1692769154


##########
components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2Consumer.java:
##########
@@ -473,4 +437,339 @@ private void logException(Exception e, 
List<ChangeMessageVisibilityBatchRequestE
         }
     }
 
+    /**
+     * Task responsible for polling the messages from Amazon SQS server.
+     *
+     * Depending on the configuration, the polling may involve sending one or 
more receive requests in a single task
+     * call. The number of send requests depends on the {@link 
Sqs2Endpoint#getMaxMessagesPerPoll()} configuration. The
+     * Amazon SQS receive API has upper limit of maximum
+     *
+     * <pre>
+     * 10
+     * </pre>
+     *
+     * messages that can be fetched with a single request. To enable handling 
greater number of messages fetched per
+     * poll, multiple requests are being send asynchronously and then joined 
together. To preserver the ordering, the
+     * messages are sorted by the sequence number attribute.
+     *
+     * In addition to that, the task is also responsible for handling 
auto-creation of the SQS queue, when its missing.
+     * The queue is created when receive request returns an error about the 
missing queue and the
+     * {@link Sqs2Configuration#isAutoCreateQueue()} is enabled. In such case, 
the queue will be created and the task
+     * will return empty list of messages.
+     *
+     * If the queue creation fails with an error related to recently deleted 
queue, the queue creation will be postponed
+     * for at least 30 seconds. To prevent task from blocking the consumer 
thread, the 30 second timeout is being
+     * checked in each task call. If the scheduled time for queue 
auto-creation was not reached yet, the task will
+     * simply return empty list of messages. Once the scheduled time is 
reached, another queue creation attempt will be
+     * made.
+     */
+    private static class PollingTask implements 
Callable<List<software.amazon.awssdk.services.sqs.model.Message>>, Closeable {
+        /**
+         * The maximum number of messages that can be requested in a single 
request to AWS SQS.
+         */
+        private static final int MAX_NUMBER_OF_MESSAGES_PER_REQUEST = 10;
+
+        /**
+         * The maximum number of threads used for receive requests.
+         */
+        private static final int MAX_NUMBER_OF_CONCURRENT_REQUESTS = 50;

Review Comment:
   Doubt: I guess this parameter should be configurable.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to