spring-attic / spring-cloud-aws

All development has moved to https://github.com/awspring/spring-cloud-aws Integration for Amazon Web Services APIs with Spring
https://awspring.io/
Apache License 2.0
591 stars 373 forks source link

SQS change message visibility #92

Open unniksk opened 9 years ago

unniksk commented 9 years ago

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.

alainsahli commented 9 years ago

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" />
artembilan commented 8 years ago

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.

uweschaefer commented 8 years ago

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 commented 8 years ago

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

uweschaefer commented 8 years ago

apparently not. never mind.

aemruli commented 7 years ago

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

BernhardBln commented 7 years ago

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)