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

Thoughts on making the PersistentApplicationEventMulticaster.invokeTargetListener method public #553

Open
JakeTiritilli opened this issue Apr 12, 2024 · 3 comments
Assignees
Labels
in: event publication registry Event publication registry meta: waiting for feedback Waiting for feedback of the original reporter

Comments

@JakeTiritilli
Copy link

JakeTiritilli commented Apr 12, 2024

Hi, I was wondering if it would be possible to make the PersistentApplicationEventMulticaster.invokeTargetListener(TargetEventPublication) method or some version of it public so that it can be invoked directly.

We have a use case where we built a couple child tables that are associated with the event_publication table to keep track of the number of times an event has been retried. Because of this, we've written our own query to find the list of event publications that need to be resubmitted and would like to be able to invoke the target listener for each one without having a second query be executed. The resubmitIncompletePublications method works, but it's running the findIncompletePublications query each time it's invoked, which is a fairly costly operation given that we already have all of the required data in memory.

@pcuriel
Copy link

pcuriel commented Apr 15, 2024

Interested in this as well.

I think invokeTargetListener may make sense to be exposed as part of IncompleteEventPublications interface. Maybe resubmitIncompletePublication(TargetEventPublication)?

@odrotbohm
Copy link
Member

Can you elaborate how you'd get hold of individual TargetEventPublications? Via the EventPublicationRegistry I assume?

@odrotbohm odrotbohm added in: event publication registry Event publication registry meta: waiting for feedback Waiting for feedback of the original reporter labels Apr 16, 2024
@odrotbohm odrotbohm self-assigned this Apr 16, 2024
@JakeTiritilli
Copy link
Author

For our use case, we wrote our own EventPublication entity so that associations with child tables that we built could be added. I wanted to be able to retrieve all of the results with one JPQL query that does a join. This is a bit of an oversimplification, but the code would look something like this:

var retryableEventPublications = eventPublicationRepo.findRetryableEventPublications();

for (var eventPublication : retryableEventPublications) {
    var targetEventPublication = TargetEventPublication.of(
          deserializeEvent(eventPublication.getSerializedEvent(), eventPublication.getEventType()),
          PublicationTargetIdentifier.of(eventPublication.getListenerId()),
          eventPublication.getPublicationDate());

    applicationEventMulticaster.invokeTargetListener(targetEventPublication);
}

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

3 participants