I was trying to stop the SqsMessageDrivenChannelAdapter
when calling stop()
I was receiving the following error:
java.util.concurrent.TimeoutException: null
at java.util.concurrent.FutureTask.get(FutureTask.java:205)
at org.springframework.cloud.aws.messaging.listener.SimpleMessageListenerContainer.stop(SimpleMessageListenerContainer.java:197)
at org.springframework.cloud.aws.messaging.listener.SimpleMessageListenerContainer.doStop(SimpleMessageListenerContainer.java:133)
at org.springframework.cloud.aws.messaging.listener.AbstractMessageListenerContainer.stop(AbstractMessageListenerContainer.java:329)
at org.springframework.cloud.aws.messaging.listener.SimpleMessageListenerContainer.stop(SimpleMessageListenerContainer.java:1)
at org.springframework.integration.aws.inbound.SqsMessageDrivenChannelAdapter.doStop(SqsMessageDrivenChannelAdapter.java:140)
at org.springframework.integration.endpoint.AbstractEndpoint.stop(AbstractEndpoint.java:111)
First indications I thought it was a time out was not long enough, after looking into the issue I found the stopping thread and the running thread are waiting for each other and the TimeoutException
would always happen. I fixed this by the follow piece of code:
new Thread() {
public void run()
{
sqsMessageRawDataChannelAdapter.stop();
LockSupport.parkNanos(TimeUnit.SECONDS.toNanos(5));
}
}.start();
I now no longer get the TimeoutException
as the thread is able to stop. Have I done something wrong, or is this an issue?