spring-cloud-aws
spring-cloud-aws copied to clipboard
SQS change message visibility
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.
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" />
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.
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.
would it be reasonable to work on that and provide a PR?
apparently not. never mind.
@uweschaefer any PR is welcome if we can integrate. Nevertheless I move this issue to 1.2.x line
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)