Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request - ability to stop SQS long-polling #655

Closed
flozano opened this issue Mar 13, 2016 · 6 comments
Closed

Feature request - ability to stop SQS long-polling #655

flozano opened this issue Mar 13, 2016 · 6 comments
Assignees
Labels
feature-request A feature should be added or improved.

Comments

@flozano
Copy link

flozano commented Mar 13, 2016

It would be great if it was possible to interrupt threads which are waiting in a receiveMessage call. It's really inconvenient when shutting down the application in an ordered way to have to wait for the whole long-poll request to finish.

I tried with thread.interrupt but the request continues.

@varunnvs92 varunnvs92 added the feature-request A feature should be added or improved. label Mar 14, 2016
@zhangzhx zhangzhx self-assigned this Mar 16, 2016
@fulghum
Copy link
Contributor

fulghum commented May 10, 2016

Thanks for the feature request Francisco. I'm surprised thread.interrupt doesn't do it; it seems like that's what we'd want to support. We should debug through that and see if we can find some clues.

@fernomac
Copy link
Contributor

Blocking socket reads don't respect Thread.interrupt. Closing the socket (via shutdown() on the client) should do it?

@flozano
Copy link
Author

flozano commented Aug 26, 2016

@shorea closing this means it's solved?

@shorea
Copy link
Contributor

shorea commented Aug 26, 2016

Since we haven't heard back I assume you tried @fernomac's suggestion and shutdown the client. If not could you try that and see if it meets your needs?

@davidmoten
Copy link
Contributor

All good! I've just tested this and confirm that shutting down the client cancels the long-poll. An exception is thrown by the long-poll request when client is shutdown like this:

java.lang.IllegalStateException: Connection pool shut down
    at org.apache.http.util.Asserts.check(Asserts.java:34)
    at org.apache.http.pool.AbstractConnPool.lease(AbstractConnPool.java:184)
    at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.requestConnection(PoolingHttpClientConnectionManager.java:251)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at com.amazonaws.http.conn.ClientConnectionManagerFactory$Handler.invoke(ClientConnectionManagerFactory.java:76)
    at com.amazonaws.http.conn.$Proxy2.requestConnection(Unknown Source)
    at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:175)
    at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
    at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)
    at com.amazonaws.http.apache.client.impl.SdkHttpClient.execute(SdkHttpClient.java:72)
    at com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:895)
    at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:736)
    at com.amazonaws.http.AmazonHttpClient.doExecute(AmazonHttpClient.java:487)
    at com.amazonaws.http.AmazonHttpClient.executeWithTimer(AmazonHttpClient.java:448)
    at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:397)
    at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:378)
    at com.amazonaws.services.sqs.AmazonSQSClient.doInvoke(AmazonSQSClient.java:1750)
    at com.amazonaws.services.sqs.AmazonSQSClient.invoke(AmazonSQSClient.java:1720)
    at com.amazonaws.services.sqs.AmazonSQSClient.receiveMessage(AmazonSQSClient.java:1370)
    at Sqs.main(Sqs.java:74)

@adrian-baker
Copy link

It's pretty messy spamming the log with IllegalStateException on shutdown.

eg, let's say your Spring Boot application fails to start up due to another error, and immediately shuts down. A valid, useful exception is now obscured by bad shutdown handling in the AWS SDK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature should be added or improved.
Projects
None yet
Development

No branches or pull requests

8 participants