dusterio / laravel-plain-sqs

Custom SQS connector for Laravel (or Lumen) that supports third-party, plain JSON messages
MIT License
131 stars 93 forks source link

Update LaravelServiceProvider.php #8

Open JordanDalton opened 7 years ago

JordanDalton commented 7 years ago

Let the developer determine when the job gets deleted. If $event->job->delete() was kept jobs would be deleted regardless if handle() was successful.

dusterio commented 7 years ago

Hmm, have you actually tried this after patch? The reason I added this block - jobs would never get deleted at all so I had to do it manually.

JordanDalton commented 7 years ago

I'm able to delete them manually afterwards.

dusterio commented 7 years ago

Manually? But successful jobs should get deleted automatically?

JordanDalton commented 7 years ago

When successful, yes. How Queue:after() was set it was deleting it regardless if was successful or not. So here's what I do as an example to control when the job gets deleted.

try {

    // do something successfully

    $job->delete();

} catch(Exception $e){

    $job->release();
}
marjanSterjev commented 7 years ago

The documentation at https://laravel.com/docs/5.1/queues states: "... The Queue::after method allows you to register a callback to be executed when a queued job executes successfully. ..."

So Queue::after is not called if the job was not executed successfully.

cristiangrama commented 5 years ago

See this https://github.com/dusterio/laravel-plain-sqs/pull/9#issuecomment-493636934