We are trying to read from an Amazon SQS Queue from a Java program running on an EC2 instance. On occasion, we get a com.amazonaws.AbortedException
. Our code looks like this:
AmazonSQSClient sqs = new AmazonSQSClient(myCredentials);
ReceiveMessageRequest request = new ReceiveMessageRequest()
.withWaitTimeSeconds(20)
.withMaxNumberOfMessages(1)
.withQueueUrl(queueUrl);
ReceiveMessageResult result = sqs.receiveMessage(request);
And our stack trace looks like this:
com.amazonaws.AbortedException:
at com.amazonaws.internal.SdkFilterInputStream.abortIfNeeded(SdkFilterInputStream.java:51)
at com.amazonaws.internal.SdkFilterInputStream.read(SdkFilterInputStream.java:65)
at com.amazonaws.event.ProgressInputStream.read(ProgressInputStream.java:159)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager$RewindableInputStream.read(XMLEntityManager.java:2890)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:674)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startEntity(XMLEntityManager.java:1304)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startDocumentEntity(XMLEntityManager.java:1255)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.setInputSource(XMLDocumentScannerImpl.java:253)
at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.setInputSource(XMLStreamReaderImpl.java:199)
at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.<init>(XMLStreamReaderImpl.java:184)
at com.sun.xml.internal.stream.XMLInputFactoryImpl.getXMLStreamReaderImpl(XMLInputFactoryImpl.java:277)
at com.sun.xml.internal.stream.XMLInputFactoryImpl.createXMLStreamReader(XMLInputFactoryImpl.java:129)
at com.sun.xml.internal.stream.XMLInputFactoryImpl.createXMLEventReader(XMLInputFactoryImpl.java:78)
at com.amazonaws.http.StaxResponseHandler.handle(StaxResponseHandler.java:91)
at com.amazonaws.http.StaxResponseHandler.handle(StaxResponseHandler.java:43)
at com.amazonaws.http.response.AwsResponseHandlerAdapter.handle(AwsResponseHandlerAdapter.java:70)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleResponse(AmazonHttpClient.java:1501)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeOneRequest(AmazonHttpClient.java:1222)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1035)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:747)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:721)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:704)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$500(AmazonHttpClient.java:672)
at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:654)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:518)
at com.amazonaws.services.sqs.AmazonSQSClient.doInvoke(AmazonSQSClient.java:1663)
at com.amazonaws.services.sqs.AmazonSQSClient.invoke(AmazonSQSClient.java:1639)
at com.amazonaws.services.sqs.AmazonSQSClient.receiveMessage(AmazonSQSClient.java:1269)
at <our code>
The documentation for com.amazonaws.services.sqs.AmazonSQSClient
does not tell us to expect an AbortedException.
We are using SDK version 1.11.77.
Any help would be appreciated. Thanks.
Though the javadoc on AbortedException
is sparse, it is a subclass of AmazonClientException
& RuntimeException
(which do not have to be declared). Also, the AWS Exception handling docs says this:
AmazonClientException indicates that a problem occurred inside the Java client code, either while trying to send a request to AWS or while trying to parse a response from AWS. An AmazonClientException is generally more severe than an AmazonServiceException, and indicates a major problem that is preventing the client from making service calls to AWS services. For example, the AWS SDK for Java throws an AmazonClientException if no network connection is available when you try to call an operation on one of the clients.
AbortedException
is generally thrown when the SDK handles an InterruptedException
(ie: the thread was signalled to stop doing work). For your purposes though, you probably just want to retry the operation.
(If you're the one doing the explicit Thread.interrupt
to cause this though, then it's up to you on how you want to proceed - either treat it as a signal to stop work, or just retry the operation)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With