Change default queue to database

This commit is contained in:
David Bomba 2020-11-22 22:14:49 +11:00
parent 6eaf78a1d5
commit e55de0fb1b
5 changed files with 39 additions and 13 deletions

View File

@ -162,8 +162,17 @@ class CreateEntityPdf implements ShouldQueue
//todo - move this to the client creation stage so we don't keep hitting this unnecessarily
Storage::makeDirectory($path, 0775);
$pdf = $this->makePdf(null, null, $maker->getCompiledHTML(true));
$pdf = null;
try {
$pdf = $this->makePdf(null, null, $maker->getCompiledHTML(true));
}
catch(\Exception $e) {
info(print_r($e->getMessage(),1));
}
if($pdf)
$instance = Storage::disk($this->disk)->put($file_path, $pdf);
return $file_path;

View File

@ -35,6 +35,12 @@ class BaseMailerJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public $tries = 5; //number of retries
public $backoff = 5; //seconds to wait until retry
public $deleteWhenMissingModels = true;
public function setMailDriver()
{
App::forgetInstance('translator');

View File

@ -32,6 +32,14 @@ class WebhookHandler implements ShouldQueue
private $event_id;
private $company;
public $tries = 5; //number of retries
public $backoff = 5; //seconds to wait until retry
public $deleteWhenMissingModels = true;
/**
* Create a new job instance.
*
@ -50,28 +58,26 @@ class WebhookHandler implements ShouldQueue
*
* @return bool
*/
public function handle() :bool
public function handle()
{//todo set multidb here
MultiDB::setDb($this->company->db);
if (! $this->company || $this->company->is_disabled) {
if (! $this->company || $this->company->is_disabled)
return true;
}
$subscriptions = Webhook::where('company_id', $this->company->id)
->where('event_id', $this->event_id)
->get();
if (! $subscriptions || $subscriptions->count() == 0) {
return true;
}
if (! $subscriptions || $subscriptions->count() == 0)
return;
$subscriptions->each(function ($subscription) {
$this->process($subscription);
});
return true;
}
private function process($subscription)

View File

@ -46,8 +46,6 @@ class InvoicePaidActivity implements ShouldQueue
{
MultiDB::setDb($event->company->db);
$event->invoice->service()->touchPdf();
$fields = new stdClass;
$fields->invoice_id = $event->invoice->id;
@ -56,5 +54,12 @@ class InvoicePaidActivity implements ShouldQueue
$fields->activity_type_id = Activity::PAID_INVOICE;
$this->activity_repo->save($fields, $event->invoice, $event->event_vars);
try {
$event->invoice->service()->touchPdf();
}
catch(\Exception $e){
info(print_r($e->getMessage(),1));
}
}
}

View File

@ -13,7 +13,7 @@ return [
|
*/
'default' => env('QUEUE_CONNECTION', 'sync'),
'default' => env('QUEUE_CONNECTION', 'database'),
/*
|--------------------------------------------------------------------------