Replies: 1 comment
-
|
I think one solution will be, for example, inside the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I'm working with Symfony 5.4 and SchedulerBundle 0.10.2, and I'm trying to do some logic when my command fails. I connected an
EventSubscriberto listen to theTaskFailedEventand send some payload to an endpoint with information of the issue.But I found out that if something wrong happens in your command (or task) doesn't mean that that will cause a "TaskFailedEvent".
So how convert a
CommandTaskwithexecution_state'errored' into aFailedTaskso that can triggerTaskFailedEvent? There's way to convert inside the command itself? Meaning to throw some exception or flagged it to be consider it as a possible FailedTask?For example say that my command is:
If I run
bin/console scheduler:consume, inside a WorkerSleepingEvent listener I found that the task is in theeventsarray of theTaskEventListobject and that is part of theTaskExecutedEvent. Inside of the task I can see thatexecution_stateiserrored.I checked the code and found that if anything goes wrong in my command will be catch by Application:
when this code returns to vendor/symfony/framework-bundle/Console/Application.php and then to vendor/guikingone/scheduler-bundle/src/Runner/CommandTaskRunner.php the code only returns an Output object:
In Worker class if there's an error with the Runner (no the command) will create a $failedTask and dispatch a TaskFailedEvent
After all that investigation, I decide to do this in my command:
But the problem is that the command is no the same as the one that failed and I will no get the datetime values to, for example, calculate how much it took to execute the command.
So how can I convert the task to
FailedTask? There's something in the package that can help me with that? The behavior that I (kinda) described is the expected one?Thank you!
Beta Was this translation helpful? Give feedback.
All reactions