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

Send Multiple different jobs to same QUEUE #14

Open
narsariamanu opened this issue Jul 17, 2017 · 6 comments
Open

Send Multiple different jobs to same QUEUE #14

narsariamanu opened this issue Jul 17, 2017 · 6 comments

Comments

@narsariamanu
Copy link

I am using Lumen 5.4.
I have multiple different jobs that I want to send to the same queue.
In essence, I want to use the job part of the payload as well.
Is there any way to do it.

@dusterio
Copy link
Owner

Of course you can - it's up to you :) You can save whatever you want in the SQS, as long as it fits in the maximum message size.

You just have to implement your own logic - how you choose what to do with the job/payload once you receive it somewhere

@narsariamanu
Copy link
Author

@dusterio Every job that I am pushing is being handled by the default-handler and not by its respective handler. Am I missing something? Please help.

@dusterio
Copy link
Owner

Oh I see what you mean. Why don't you create some kind of intermediary class that fetches the payload, sees what's inside and then decides to which Job class to pass it?

What you are implementing is not really a plain SQS/JSON anymore because you want to have some important metadata in it. I'm not sure if it should be an optional part of this package or not (maybe it should)

@cristiangrama
Copy link

The handlers point to the queue name. Therefore you can only have one job per sqs queue.

The easiest option is to save a type in the payload and use a handler job. Then look at the type and using the factory pattern you can process the job the holds the logic for what you want by using regular Jobs and then dispatch them to be processed synchronously.

@ejunker
Copy link

ejunker commented Jun 24, 2019

The Dusterio\PlainSqs\Sqs\Queue::pop() method has code where it determines which Job class to use based on the config which maps queues to handlers. I think that could be extracted into a method like resolveClass($queue, $response). Then add a setter to allow the user to set their own class resolver method so that they have control over which job class to use. It would use the default class resolver method which uses the config unless it was overridden.

@dusterio
Copy link
Owner

@ejunker wanna make a PR? :)

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

4 participants