Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Receiving from SQS: HandlerJob example does not show namespace #40

Open
olivertappin opened this issue Dec 10, 2019 · 1 comment
Open

Comments

@olivertappin
Copy link

olivertappin commented Dec 10, 2019

Given the example shown within the README.md file, we are given the following code snippet under Receiving from SQS:

use Illuminate\Contracts\Queue\Job as LaravelJob;

class HandlerJob extends Job
{
    protected $data;

    /**
     * @param LaravelJob $job
     * @param array $data
     */
    public function handle(LaravelJob $job, array $data)
    {
        // This is incoming JSON payload, already decoded to an array
        var_dump($data);

        // Raw JSON payload from SQS, if necessary
        var_dump($job->getRawBody());
    }
}

However, it's not clear what class the HandlerJob class is extending. We are just presented with Job.

We can see that:

  1. Illuminate\Contracts\Queue\Job is already has an alias (and is an interface), so it's not going to be using that class.
  2. The Illuminate\Queue\Jobs\Job is another potential, but that requires us to declare two methods declared in the abstract class: getRawBody and getJobId.
  3. Using Illuminate\Queue\Jobs\SqsJob which seems like a potential match, throws an error when attempting to be consumed:
[2019-12-10 21:36:46] local.ERROR: Unresolvable dependency resolving [Parameter #0 [ <required> array $config ]] in class Aws\Sqs\SqsClient {"exception":"[object] (Illuminate\\Contracts\\Container\\BindingResolutionException(code: 0): Unresolvable dependency resolving [Parameter #0 [ <required> array $config ]] in class Aws\\Sqs\\SqsClient at /Users/oliver/Sites/xxx/vendor/laravel/framework/src/Illuminate/Container/Container.php:994)

So I'm a little confused with how this example should be working to receive messages from the SQS queue, and allow the handler to work on them.

Any suggestions would be helpful.

@olivertappin olivertappin changed the title README.md HandlerJob class does not show namespace Receiving from SQS: HandlerJob example does not show namespace Dec 10, 2019
@olivertappin
Copy link
Author

After further testing, it seems Illuminate\Queue\Jobs\Job is the class in question, and you must implement the getRawBody and getJobId to satisfy the requirements of the abstract class. I will open a PR to reflect these changes on the README.md file.

thursdaydan added a commit to thursdaydan/laravel-plain-sqs that referenced this issue Jan 3, 2025
Removed the extends Job statement and the use alias from the readme example as per the following issue:

dusterio#40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant