How to retry with custom actions?

When executing a custom campaign action I can set the result with $event->setResult(true) or $event->setFailed('some reason').

I want the action to be retried over and over until it’s finished. I tried setResult(false), setFailed('pending'), and not calling setResult or setFailed at all. In any case the action is not retried again, it runs only once.

Is it possible to have an custom action to run again and again and again until I set it to stop?

1 Like

I tried to reproduce and came to same issue as you. I couldn’t even find in database where the failed flag is set so it could be that we are using older version of class which is going to be depreciated ?

/**
 * Class CampaignExecutionEvent.
 *
 * @deprecated 2.13.0; to be removed in 3.0
 */
class CampaignExecutionEvent extends Event

Hi @mayanktiwaridotcom thanks for your reply.

My problem was that I was not waiting the needed time to the rescheduled action to execute. What I did was set campaign retry time to 0, but for my surprise this was not rescheduling the task. I even created an PR about it: https://github.com/mautic/mautic/pull/8884

So what I did to test this was to add a new 2 seconds retry time to campaign retry intervals (Settings -> Configuration -> Campaign Settings) so that app/console --env=dev mautic:campaign:trigger execute the action without the need to wait for 15 minutes. To do this I edited the app/bundles/CampaignBundle/Form/Type/ConfigType.php file, add 'PT2S' => '2 s', to the intervals list, cleanup the cache, refreshed the page, selected the 2s from Settings -> Configuration -> Campaign Settings. After this I can run app/console --env=dev mautic:campaign:trigger and get it the action retried over and over and over again.

We may have an option like this for development only so that we can test custom actions without resorting to this kind of hack, but I didn’t want to burden the PR with this.

The database entries that I found was in <prefix>campaign_lead_event_log table, I didn’t fully understand the success/failure vs rescheduling logic, but the rows are there (at last are in my case)

I didn’t tried the 3.0 release yet,

BTW, sorry for lately replying this, I’ll check my notification settings.