amazon-sqs-java-messaging-lib
amazon-sqs-java-messaging-lib copied to clipboard
Would I be able to set visibility timeout for message using amazon sqs jms lib?
I have multiple threads running concurrently. And since one message's execution might be dependent on another, after checking state of previous message's execution state, I want the message to remain invisible till the previous message execution is completed. Would it be possible to set visibility timeout for the message when using amazon sqs - jms integration?
+1
+1
Shame to see this feature request still open. Its been 2 years and this lib doesn't support configuring visibility timeout. The way to do this is move to JMS specification 2.0. I hope someone takes it up.
+1 @robin-aws
FWIW, this can be accomplished by calling AmazonSQS::changeMessageVisibility. Give the method annotated with @JmsListener an arg of type SQSTextMessage. That class has both getQueueUrl and getRecieptHandle methods which are the two pieces of info needed to set visibility timeout.
Thanks @markmelville but this does not accomplish the same effect as setting a .visibilityTimeout() parameter in the receiveMessages call. Injecting it in the @Listener and changing the visibility there, adds some time between the reception of the message in the SQS client and the reception at the Spring bean. In this time, another thread could issue a receiveMessages and get the message duplicated. The only solution to this problem is to add a parameter in the configuration to include a .visibilityTimeout() in the receiveMessages operation, so only one thread can receive each message at a time.
Why has it been closed as completed? I've looked at the changes in 2.0.2 and I don't see anywhere any new option to configure the visibility timeout of received messages.