amazon-sqs-java-messaging-lib icon indicating copy to clipboard operation
amazon-sqs-java-messaging-lib copied to clipboard

Would I be able to set visibility timeout for message using amazon sqs jms lib?

Open pratikshya opened this issue 8 years ago • 4 comments

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?

pratikshya avatar Apr 05 '17 00:04 pratikshya

+1

osamahq avatar Sep 06 '17 10:09 osamahq

+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.

apexkid avatar Aug 11 '19 22:08 apexkid

+1 @robin-aws

ssharma avatar Jan 10 '20 16:01 ssharma

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.

markmelville avatar Jan 15 '20 18:01 markmelville

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.

getaceres avatar Nov 10 '22 10:11 getaceres

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.

getaceres avatar Dec 13 '22 16:12 getaceres