spring-cloud-aws icon indicating copy to clipboard operation
spring-cloud-aws copied to clipboard

SQS change message visibility

Open unniksk opened this issue 9 years ago • 7 comments

Is there any way to change message visibility of SQS messages.

@MessageMapping("SQS_URL)
public void queueListener(String message,@Header("ReceiptHandle") String receiptHandle) throws Exception {
   amazonSqs.changeMessageVisibility(new ChangeMessageVisibilityRequest(sqsURL, amazonMessage.getReceiptHandle(),120));
}

This might change the visibility but the message gets deleted from the queue.

unniksk avatar Aug 18 '15 11:08 unniksk

Hi @unniksk You can set the visibility using XML or Java Config:

@Bean
public SimpleMessageListenerContainerFactory simpleMessageListenerContainerFactory() {
    SimpleMessageListenerContainerFactory factory = new SimpleMessageListenerContainerFactory();
    factory.setVisibilityTimeout(20);

    return factory;
}
<aws-messaging:annotation-driven-queue-listener auto-startup="false" visibility-timeout="20" />

alainsahli avatar Aug 18 '15 16:08 alainsahli

See fully similar SO question on the matter http://stackoverflow.com/questions/38355551/aws-integration-spring-extend-visibility-timeout.

I'm reopening an issue since the provided solution doesn't fix the real premise.

artembilan avatar Jul 14 '16 19:07 artembilan

Same Problem here. Unless you can "guess" a good max value for Visibility Timeout, it is hard to use SQS, because the original consumer of a message could still be working without anyone knowing, when an in-Flight Messgae is redelivered.

It'd be nice, if SimpleMessageListenerContainer.MessageExecutor.Run() would prolong the timeout actively, as long as executeMessage() does not return or fail.

uweschaefer avatar Oct 07 '16 12:10 uweschaefer

would it be reasonable to work on that and provide a PR?

uweschaefer avatar Oct 07 '16 12:10 uweschaefer

apparently not. never mind.

uweschaefer avatar Nov 15 '16 17:11 uweschaefer

@uweschaefer any PR is welcome if we can integrate. Nevertheless I move this issue to 1.2.x line

aemruli avatar Feb 28 '17 21:02 aemruli

Would be nice if a maximum time and even the increment sizes could be defined, though (like, default visibility timeout which is a bit shorter, and automatic prolonging with a given time, up to the given maximum)

BernhardBln avatar Mar 30 '17 11:03 BernhardBln