spatie / laravel-webhook-client

Receive webhooks in Laravel apps
https://freek.dev/1383-sending-and-receiving-webhooks-in-laravel-apps
MIT License
1k stars 147 forks source link

dispatch job on specific connection #113

Closed slimani-dev closed 2 years ago

slimani-dev commented 3 years ago

The problem

I have few jobs in my application that Run in the Background in a database queue connection, the problem is that when i started using the database connection i lost the HTTP request information of the Webhook Job and i need the request headers

The requested feature

it would be amazing if there is an option to choose the queue connection for the Webhook job

something like this

namespace Spatie\WebhookClient;
...

class WebhookProcessor
{
    protected Request $request;

    protected WebhookConfig $config;

    ...

   protected function processWebhook(WebhookCall $webhookCall): void
    {
        try {
            $job = new $this->config->processWebhookJobClass($webhookCall);

            $webhookCall->clearException();

            dispatch($job)->onConnection('sync');

        } catch (Exception $exception) {
            $webhookCall->saveException($exception);

            throw $exception;
        }
    }

    ...

}

in line 62 of WebhookProcessor.php file

dispatch($job)->onConnection('sync');

this solution is working for me but it means i will have to edit the files every time

thank you

freekmurze commented 3 years ago

Feel free to send a PR with tests for this!