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

Marking publication of event completed updates more than one row #1008

Open
Neil-Hancock opened this issue Dec 30, 2024 · 2 comments
Open

Marking publication of event completed updates more than one row #1008

Neil-Hancock opened this issue Dec 30, 2024 · 2 comments
Assignees
Labels
in: event publication registry Event publication registry meta: waiting for feedback Waiting for feedback of the original reporter

Comments

@Neil-Hancock
Copy link

I am testing out Spring Modulith and have a requirement to push an event to two SQS queues. For now, I'm trying to handle this fan-out by publishing two events like this:

applicationEventPublisher.publishEvent(new SqsOne(payload);
applicationEventPublisher.publishEvent(new SqsTwo(payload);

The definitions of SqsOne & SqsTwo have an @Externalized on them with their own queue arn, and that works fine. The issue is once one of them completes, the update query updates multiple rows in one go. This is because only serialized_event & listener_id are in the where clause, and they are the same for a given payload as the listener_id is the same for all Externalized Listeners.

I realize using SNS for fanout, utilizing a unique field in each wrapper class, or a custom serializer would resolve this, but are there are any plans to incorporate id or and/or event_type into the update where clause so this scenario is handled by default?

I suppose supporting multiple @Externalized on a class/record would also handle this scenario quite well as it would provide native fan-out functionality.

Thanks for brining this framework to life and continuing to advance it!

@Neil-Hancock
Copy link
Author

Reviewing further, I see this is only an issue with retries as they use

EventPublicationRepository.markCompleted(Object event, PublicationTargetIdentifier identifier, Instant completionDate)

rather than

EventPublicationRepository.markCompleted(UUID identifier, Instant completionDate)

which is used if the initial handling is a success.

Based on this, I'm guessing this is a fundamental limitation which will require working around.

@odrotbohm
Copy link
Member

Fundamentally, we expect events to be unique in their serialized representations. Usually, event types carry some sort of unique identifier (UUID.randomUUID()). That said, do SqsOne and SqsTwo have proper equals(…) and hashCode() methods implemented? That is crucial to for the listener completion advice to obtain the original event publication to be able to mark them as completed via the publication's identifier.

@odrotbohm odrotbohm self-assigned this Jan 10, 2025
@odrotbohm odrotbohm added in: event publication registry Event publication registry meta: waiting for feedback Waiting for feedback of the original reporter labels Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: event publication registry Event publication registry meta: waiting for feedback Waiting for feedback of the original reporter
Projects
None yet
Development

No branches or pull requests

2 participants