[
https://issues.apache.org/jira/browse/BEAM-4828?focusedWorklogId=132813&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-132813
]
ASF GitHub Bot logged work on BEAM-4828:
----------------------------------------
Author: ASF GitHub Bot
Created on: 09/Aug/18 03:21
Start Date: 09/Aug/18 03:21
Worklog Time Spent: 10m
Work Description: rangadi commented on a change in pull request #6101:
[BEAM-4828] Add Amazon SqsIO
URL: https://github.com/apache/beam/pull/6101#discussion_r208796453
##########
File path:
sdks/java/io/amazon-web-services/src/main/java/org/apache/beam/sdk/io/aws/sqs/SqsUnboundedReader.java
##########
@@ -0,0 +1,166 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.sdk.io.aws.sqs;
+
+import com.amazonaws.services.sqs.model.Message;
+import com.amazonaws.services.sqs.model.MessageSystemAttributeName;
+import com.amazonaws.services.sqs.model.ReceiveMessageRequest;
+import com.amazonaws.services.sqs.model.ReceiveMessageResult;
+import java.io.Serializable;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayDeque;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.Queue;
+import org.apache.beam.sdk.io.UnboundedSource;
+import org.apache.beam.sdk.io.UnboundedSource.CheckpointMark;
+import org.apache.beam.sdk.transforms.windowing.BoundedWindow;
+import org.joda.time.Instant;
+
+class SqsUnboundedReader extends UnboundedSource.UnboundedReader<Message>
implements Serializable {
+
+ public static final int MAX_NUMBER_OF_MESSAGES = 10;
+ private final SqsUnboundedSource source;
+ private Message current;
+ private final Queue<Message> messagesNotYetRead;
+ private List<Message> messagesToDelete;
+ private Instant oldestPendingTimestamp = BoundedWindow.TIMESTAMP_MIN_VALUE;
+
+ public SqsUnboundedReader(SqsUnboundedSource source, SqsCheckpointMark
sqsCheckpointMark) {
+ this.source = source;
+ this.current = null;
+
+ this.messagesNotYetRead = new ArrayDeque<>();
+ this.messagesToDelete = new ArrayList<>();
+
+ if (sqsCheckpointMark != null) {
+ this.messagesToDelete.addAll(sqsCheckpointMark.getMessagesToDelete());
+ }
+ }
+
+ @Override
+ public Instant getWatermark() {
Review comment:
It is a logical stuckness, i.e. if the source does not advance the
watermark, the windows based on data watermark (this is the default) don't
fire. E.g. say a pipeline producing aggregates every minute using 1-minute
fixed windows. A message arrives at 10:30:05 and nothing for next one hour.
When should the aggregates for minute '10:30' be produced? Ideally should be
soon after 10:31:00. What would happen with this source in that case?
Please note that I am not asking this to be fixed, but better to clearly
document the behavior. Managing watermark is one of most important aspects of a
unbounded source.
E.g. while using LogAppendTime in KafkaIO, if a partition is idle, the
watermark for the partition progresses to `(now - 2 seconds)` (see
[here](https://github.com/apache/beam/blob/master/sdks/java/io/kafka/src/main/java/org/apache/beam/sdk/io/kafka/TimestampPolicyFactory.java#L158)).
Justification is that if the partition receives any new message its timestamp
will be in future (2 seconds is to account for any unknown buffering/delays
inside the Kafka server itself).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 132813)
Time Spent: 8h 20m (was: 8h 10m)
> Add Amazon SqsIO
> ----------------
>
> Key: BEAM-4828
> URL: https://issues.apache.org/jira/browse/BEAM-4828
> Project: Beam
> Issue Type: New Feature
> Components: io-java-aws
> Reporter: John Rudolf Lewis
> Assignee: John Rudolf Lewis
> Priority: Major
> Time Spent: 8h 20m
> Remaining Estimate: 0h
>
> Add an SQS source
>
> For people who would like to follow progress or help out:
> [https://github.com/JohnRudolfLewis/beam/tree/Add-SqsIO]
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)