simon-ras commented on code in PR #11102:
URL: https://github.com/apache/camel/pull/11102#discussion_r1294523629
##########
components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2Consumer.java:
##########
@@ -404,32 +410,44 @@ public void cancel() {
@Override
public void run() {
if (run.get()) {
- ChangeMessageVisibilityRequest.Builder request
- =
ChangeMessageVisibilityRequest.builder().queueUrl(getQueueUrl()).visibilityTimeout(repeatSeconds)
-
.receiptHandle(exchange.getIn().getHeader(Sqs2Constants.RECEIPT_HANDLE,
String.class));
-
- try {
- LOG.trace("Extending visibility window by {} seconds for
exchange {}", this.repeatSeconds, this.exchange);
-
getEndpoint().getClient().changeMessageVisibility(request.build());
- LOG.debug("Extended visibility window by {} seconds for
exchange {}", this.repeatSeconds, this.exchange);
- } catch (MessageNotInflightException |
ReceiptHandleIsInvalidException e) {
- // Ignore.
- } catch (SqsException e) {
- if (e.getMessage().contains("Message does not exist or is
not available for visibility timeout change")) {
+
+ List<ChangeMessageVisibilityBatchRequestEntry> entries = new
LinkedList<>();
+
+ while (!requestQueue.isEmpty()) {
+
+ // up to 10 requests can be sent with each
ChangeMessageVisibilityBatch action
+ while (!requestQueue.isEmpty() && entries.size() <
MAX_REQUESTS) {
+ entries.add(requestQueue.poll());
Review Comment:
The entry should only be removed from this queue once it has been processed
by the consumer.
The current solution will only extend the message a single time. Also I
cannot see where you remove the entry from the extend queue once it has been
fully processed.
I think it would be better if the consumer itself had a collection of
in-flight exchanges - and then the extender would iterate that collection. The
consumer then has to remove the exchanges once fully processed.
--
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]