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

Feature/persist webhook events #24

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

VSydor
Copy link
Contributor

@VSydor VSydor commented Oct 4, 2021

No description provided.

@VSydor VSydor requested a review from brmeyer October 4, 2021 12:51
@VSydor VSydor force-pushed the feature/persist_failed_payment_events branch 2 times, most recently from 3d3e173 to 8b89465 Compare October 4, 2021 18:51
@VSydor VSydor force-pushed the feature/persist_failed_payment_events branch 2 times, most recently from 5b7b368 to e6d985e Compare October 7, 2021 12:03
@Setter
@Entity
@Table(name = "failed_request", schema = "public")
public class FailedRequest {
Copy link
Contributor

Choose a reason for hiding this comment

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

@VSydor Re: what we were talking about yesterday, wondering if we should refactor this to make it more of a WebhookRequest class. I think the fields can be kept the same, but we'd switch to inserting this at the beginning of every single webhook Controller method. If processing fails, update it with the errorMessage? If it succeeds, delete it? Or possibly retain it for 7ish days in case we need to analyze it?

That will get us one step closer to creating a durable, async queue...

Thoughts? CC @LandonBaer721

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As I see it:
if we want to keep track of every single incoming event - then we should do it like you said: persist on each request and then update with an error message if processing failed (and keep "successful events" for some longer time. But how do we clean-up them later on? Will have to do it manually in some way?).

if the idea is to track only failed-to-process events - then there is no need to persist every event - only failed ones (and then delete them after successful processing?)

Please let me know which approach is preferred - I'll update the code.

} catch (Exception e) {
log.error("failed to process the Stripe event", e);
// TODO: email notification?
log.info("Saving event with id '{}' as failed request...", event.getId());
env.failedRequestService().persist(event.getId(), new JSONObject(event), e.getMessage());
Copy link
Contributor

Choose a reason for hiding this comment

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

IE, shift this to the beginning of the webhook method, then replace this line with an update to mark it as failed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will update

@VSydor VSydor force-pushed the feature/persist_failed_payment_events branch from e6d985e to c1d6ad1 Compare November 4, 2021 00:29
@VSydor VSydor changed the title Feature/persist failed payment events Feature/persist webhook events Nov 4, 2021
@VSydor VSydor requested a review from brmeyer November 4, 2021 00:32
@VSydor VSydor force-pushed the feature/persist_failed_payment_events branch from c1d6ad1 to e822f80 Compare November 4, 2021 00:38
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.

3 participants