# How to retry with custom actions?

**URL:** <https://forum.mautic.org/t/how-to-retry-with-custom-actions/14625>\
**Category:** Development\
**Created:** [June 3, 2020, 10:17pm UTC](https://forum.mautic.org/t/how-to-retry-with-custom-actions/14625 "2020-06-03T22:17:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![danielhilst](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/danielhilst/32/2132_2.png) [@danielhilst](https://forum.mautic.org/u/danielhilst)\
**Post date:** [June 3, 2020, 10:17pm UTC](https://forum.mautic.org/t/how-to-retry-with-custom-actions/14625/1 "2020-06-03T22:17:50Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![mayanktiwaridotcom](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mayanktiwaridotcom/32/1501_2.png) [@mayanktiwaridotcom](https://forum.mautic.org/u/mayanktiwaridotcom)\
**Post date:** [June 5, 2020, 6:51pm UTC](https://forum.mautic.org/t/how-to-retry-with-custom-actions/14625/2 "2020-06-05T18:51:27Z")

</div>

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
```

---

<div class="post-metadata">

**Author:** ![danielhilst](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/danielhilst/32/2132_2.png) [@danielhilst](https://forum.mautic.org/u/danielhilst)\
**Post date:** [June 30, 2020, 6:41pm UTC](https://forum.mautic.org/t/how-to-retry-with-custom-actions/14625/3 "2020-06-30T18:41:52Z")

</div>

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](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](https://github.com/mautic/mautic/pull/8884/files/977b2d8effff567345bde76650cd3adfc73821bd#diff-9a5365ef67bc7f769a0d81651c2cc927) 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.
