Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve documentation for SqsMessageListenerContainer's ability to change visiblity and performing manual acknowledgements #1130

Open
vicinzu opened this issue Apr 4, 2024 · 5 comments
Labels
component: sqs SQS integration related issue status: waiting-for-feedback Waiting for feedback from issuer

Comments

@vicinzu
Copy link

vicinzu commented Apr 4, 2024

Type: Bug

Component:
SQS (reference documentation)

Describe the bug
We have been using spring-cloud-aws for a long time to integrate SQS into our services. Until now, using the @SqsListener annotation has been sufficient.

But now we are facing new challenges. We need to define and configure the beans dynamically at runtime. For general use cases the functionality of the SqsMessageListenerContainer is great. However, we also have use cases where we need to change the visibility of individual messages and where we need to do manual acknowledgement. Unfortunately there is no documentation on how to use that functionality with the SqsMessageListenerContainer.

I had a look to the source code and it seems to me, that the message headers contain the solution:

  • visibility change: Retrieve Visibility from the message header Sqs_VisibilityTimeout to change the visibility
  • manual acknowledgement: Retrieve AcknowledgementCallback from the message header AcknowledgementCallback to perform a manual acknowledgement

But i am not sure if this is the right way of doing it:

  • is it intended for "external" use?
  • will this implementation remain stable?

Would be nice if you could update the documentation of the SqsMessageListenerContainer accordingly.

@vicinzu vicinzu changed the title Improve documentation for SqsMessageListenerContainer's ability to change visiblity and performing manual acknowledgement Improve documentation for SqsMessageListenerContainer's ability to change visiblity and performing manual acknowledgements Apr 4, 2024
@vicinzu
Copy link
Author

vicinzu commented Apr 11, 2024

PS. I can create a PR to update the documentation on my own, if i get a response to my questions. :)

I had a look to the source code and it seems to me, that the message headers contain the solution:

  • visibility change: Retrieve Visibility from the message header Sqs_VisibilityTimeout to change the visibility
  • manual acknowledgement: Retrieve AcknowledgementCallback from the message header AcknowledgementCallback to perform a manual acknowledgement

But i am not sure if this is the right way of doing it:

  • is it intended for "external" use?
  • will this implementation remain stable?

@tomazfernandes
Copy link
Contributor

Hi @vicinzu, not sure what you mean.

Manual Acknowledgement is covered in this part of the docs.

Message visibility is covered here and here

Does this help you?

Thanks.

@tomazfernandes tomazfernandes added component: sqs SQS integration related issue status: waiting-for-feedback Waiting for feedback from issuer labels Apr 15, 2024
@vicinzu
Copy link
Author

vicinzu commented Apr 15, 2024

Hi @tomazfernandes,
thanks for your reply!

Regarding the acknowledgement:
The documentation describes how to configure an AcknowledgementResultCallback ("Provides actions to be executed after a message acknowledgement completes with either success or failure") for a SqsMessageListenerContainer.

But I am searching for a way to get an instance of Acknoledgement, like in the @SqsListener method parameter, with whom i can manually acknowledge one specific message in a MessageListener.

In the source code i noticed that I can instantiate an Acknowledgement by retrieving the AcknowledgementCallback ("Interface representing an acknowledgement callback to be executed") from the message headers. I would like to know if this is the intended way of doing it and if it will be stable throughout new releases.

Regarding the visiblity:
Unfortunately in your reply you linked the very same urls as for acknowledgement. In the documentation I did not find anything specific about changing the visibility in combination with the SqsMessageListenerContainer.

I am searching for a way to get an instance of Visibility, like in the @SqsListener method parameter, with whom i can manually change the visibility one specific message in a MessageListener .

In the source code i noticed that, similar to acknowledgement, it can be retrievied from the message headers. Is this also the way to go?

Thank you in advance!

@tomazfernandes
Copy link
Contributor

But I am searching for a way to get an instance of Acknoledgement, like in the @SqsListener method parameter, with whom i can manually acknowledge one specific message in a MessageListener.

Oh, I see, you don't really have to do anything, just set AcknowledgementMode to MANUAL and add Acknowledgement to the listener method and the framework will handle this for you.

I thought this phrase would be clear enough, but maybe we can improve it or add an example?
MANUAL - The framework won’t acknowledge messages automatically and Acknowledgement objects can be received in the listener method.

Unfortunately in your reply you linked the very same urls as for acknowledgement.

Whoops, sorry, my mistake. Here and here

Is this also the way to go?

Visibility is simple as well - just add a Visibility parameter to the method listener and the framework will provide one.

Makes sense to you?

@vicinzu
Copy link
Author

vicinzu commented Apr 22, 2024

Hello @tomazfernandes,

yes I know. It is well documented for it. We already do use it like that (as mentioned in my first message).

But because we need more flexibility we want to switch from the @SqsListener annotation to custom configuration classes instantiating SqsMessageListenerContainer. But for the container there is no documentation how to implement manual acknowledgements and visibility changes. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: sqs SQS integration related issue status: waiting-for-feedback Waiting for feedback from issuer
Projects
None yet
Development

No branches or pull requests

2 participants