0

I am using this library: https://doc.akka.io/docs/alpakka/current/sqs.html for working with SQS.

I am trying to create SQS long polling with it, they provided a snippet for reading messages from SQS:

final CompletionStage<List<Message>> cs =
    SqsSource.create(
            queueUrl,
            SqsSourceSettings.create()
                .withWaitTime(Duration.ofSeconds(1)),
            sqsClient)
        .runWith(Sink.seq(), materializer);

I have used RestartSource from Akka before with Scala, but in Java, I am not able to make this polling indefinite. It stops after a few minutes. What would be a good way to keep the poller alive? Is there any other alternative in Java?

Anand Chokshi
  • 17
  • 1
  • 7
  • Does it stop when wrapped with a [RestartSource](https://doc.akka.io/docs/akka/current/stream/operators/RestartSource/onFailuresWithBackoff.html) as well? – dvim Jan 29 '19 at 11:36
  • I managed to do that with RestartSource, once I pass a negative value in maxRestart it was working properly. – Anand Chokshi Jan 29 '19 at 18:11

1 Answers1

0

You can achieve this by wrapping your source with RestartSource: https://doc.akka.io/docs/akka/current/stream/stream-error.html#delayed-restarts-with-a-backoff-operator In this, you just have to pass negative value on maxRestart. Documentation was very clear on this, I just couldn't find SQS and this section together.

Anand Chokshi
  • 17
  • 1
  • 7