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

feat(mesage-pickup): option for awaiting completion #1755

Merged

Conversation

genaris
Copy link
Contributor

@genaris genaris commented Feb 12, 2024

Add a blocking mode for MessagePickupApi.pickupMessages(), where the agent will wait until all messages have been effectively retrieved and therefore the message pickup process is completed.

This tries to solve two main situations:

  1. Retrieve queued messages BEFORE setting live mode in agents configured with MediatorPickupStrategy.PickUpV2LiveMode. This allows supporting the case where the mediator does not support live-delivery-change message (which is the case of AFJ <= 0.4.2 and AFAIK ACA-Py's Pick-up v2 plug-in). In such case, mediator will send a problem report that will be logged in the recipient but should not prevent the pick-up flow from being started
  2. Facilitate the creation of a process dedicated to message pickup only. For instance, this can be used in mobile agents that are initiated from a background notification handler.

I did not take too much effort on the tests yet as I see there are some improvements in #1754 so maybe I can incorporate them once it's reviewed and merged.

Copy link
Contributor

@TimoGlastra TimoGlastra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thansk for looking into this! How would it exactly work when you want to use a 0.4.2 mediator? pickup v2 and it will automatically use implicit afterwards?

// message pickup process (Note: this is not optimal since we'll always doing an extra
// Batch Pickup. However, it is safer and should be faster than waiting an entire loop
// interval to retrieve more messages)
if (messages.length === 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If messages.length is smaller than the batch size we can also assume the message pickup is complete right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! The issue is that I cannot be 100% sure of the batch size requested in the originating batch message (I can assume it from agent config but user can actually override it)

@TimoGlastra TimoGlastra merged commit faa390f into openwallet-foundation:main Feb 13, 2024
7 checks passed
@genaris
Copy link
Contributor Author

genaris commented Feb 13, 2024

Thansk for looking into this! How would it exactly work when you want to use a 0.4.2 mediator? pickup v2 and it will automatically use implicit afterwards?

I think you can still use PickUpV2LiveMode. The 0.4.2 agent will be unable to process the live delivery change but the socket will stay opened and it will forward the messages though it as they arrive.

@TimoGlastra
Copy link
Contributor

Okay makes sense! Maybe we should deprecate implicit mode in 0.6 and remove in 0.7 (or deprecate in 0.5.x and remove in 0.6).

Maybe we should also deprecate pickup v1 then, as there's not really a lot of adoption, and also not really any reason not to use v2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants