*/
public final function fail() {
$this->failures++;
+
+ $this->onFailure();
}
/**
* cronjob comes along).
*/
abstract public function perform();
+
+ /**
+ * Called when the job failed.
+ *
+ * Note: This method MUST NOT throw any exceptions. Doing so will lead to this job immediately
+ * being failed completely.
+ *
+ * @see AbstractBackgroundJob::fail()
+ */
+ public function onFailure() {
+ // empty
+ }
+
+ /**
+ * Called when the job failed too often. This method can be used to perform additional
+ * logging for highly important jobs (e.g. into a dedicated failed_jobs table).
+ *
+ * Note: This method MUST NOT throw any exceptions. Doing so will lead to this job immediately
+ * being failed completely.
+ *
+ * Note: Both onFailure() and onFinalFailure() will be called on the final failure.
+ *
+ * @see AbstractBackgroundJob::onFailure()
+ */
+ public function onFinalFailure() {
+ // empty
+ }
}