3

I have problem with laravel queues. In my project, default connection is sync, I want to add sqs connection for one type of jobs.

When I dispatch job in this way:

TestAction::dispatch()->onQueue('test');

Job is performed immediately (by sync connection).

If I dispatch job in this way:

TestAction::dispatch()->onQueue('test')->onConnection('sqsTestAction');

everything is ok.

Queue "test" is in sqsTestAction connection, why in first example job is being sent by sync connection?

My config/queue.php:


    'default' => env('QUEUE_CONNECTION', 'sync'),


    'connections' => [

        'sync' => [
            'driver' => 'sync',
        ],

        'sqsTestAction' => [
            'driver' => 'sqs',
            'key' => env('AWS_ACCESS_KEY_ID'),
            'secret' => env('AWS_SECRET_ACCESS_KEY'),
            'prefix' => env('AWS_SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'),
            'queue' => "test",
            'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
        ],

    ],

Laravel ver 5.8

1 Answer 1

1

why in first example job is being sent by sync connection?

Because it is set by default as you can see. Change .env file value for QUEUE_CONNECTION to sqsTestAction and that will become default. In default key of config/queue file, second parameter is fallback parameter for case when .env value doesn't exist.

Sign up to request clarification or add additional context in comments.

2 Comments

Ok, I thought the default connection did not support the test queue, so this is my misunderstanding. Thanks for the answer
Happy coding! #soReadyToHelp

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.