Support the ongoing development of Laravel.io →
Queues Architecture
Last updated 1 year ago.
0

Another, Equal Analogy

Say in a system there's a UserWasRegistered event. A subscriber to that event would a SendEmailCommand. This is handled by a handler...

But it takes a while.

So, we, in our subscriber, queue instead SendEmailWorker. The worker would call SendEmailCommand. All up, the process would be:

UserWasRegistered -> [subscribe and queue up:] -> SendEmailWorker > SendEmailCommand

Now, say the email never arrives. You want to resend the email when the user presses the "resend confirmation email" button. What happens here? Domain events suggest that you would just call the SendEmailCommand command, except that takes a long time to send the email and it holds up the UI.

I know time may be negligible for sending an email, but in the spirit of an analogy let's pretend it takes ages, much like the original example, updating composer dependences and committing back to a repository.

How would this best be handled?

Last updated 1 year ago.
0

In our systems we have a log of emails that are sent - which also maintains a status of whether it was successful or not. If it was not, it tries again, using the same command, which is passed an EmailContent object which contains the content to be sent.

One thing to be aware of is the language. CreateDependencyChange is very technical lingo. Imho, you're better off using language that represents the user actions, rather than system implementations. What did the user do? What is the language used throughout the user interface?

UpdateGitRepositoryDependency (Command) GitRepositoryDependencyUpdated (Event)

whenGitRepositoryDependencyIsUpdated (Listener)

This language represents how you've outlined the use-case, and is how (in theory), it should be implemented.

If you're looking to support other version control systems, then you could probably omit the "git" aspect so it's more generic. If you're not wanting to do that, then don't :)

Last updated 1 year ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.