huddo's avatar
Level 1

Laravel with Amazon SQS

When a job is dispatched by a code base. Is it executed by the server that is running the queue listener or by the code base that dispatched the job? I am using Amazon SQS as the queue driver

Example:

Let assume for all purposes that the code on dev.com is identical to the code on prod.com

I have a server running on dev.com. This is my development server for testing purposes.

I have my production server running on prod.com. This is my live server with live data.

I have my queue listener running on prod.com for obvious reasons.

If I dispatch a job from dev.com to send a batch email. This will be picked up by the queue listener on prod.com

Will the job use the data from dev.com or prod.com?

If I run a script to send an email to all users for testing, obviously I don't want this to be sent to all the prod.com users.

What is the best workaround for this to ensure that I am using my test data, while not pausing the queue listener on my production server?

Thank you for your help in advance

0 likes
2 replies
audunru's avatar
audunru
Best Answer
Level 4

Use two queues. Depending on how strict you are with keeping similar environments, you could use the database driver in development and SQS in prod. Or just two SQS queues.

The docs say: “When the job is actually handled, the queue system will automatically re-retrieve the full model instance from the database. It's all totally transparent to your application and prevents issues that can arise from serializing full Eloquent model instances.“

So you’ll get data from the environment that picks up the job as far as I understand it.

You could pass the environment setting to the job when dispatching it, and check that it matches when it runs, but I think two queues is cleaner.

huddo's avatar
Level 1

@AUDUNRU - Thank you for your reply. I will use seperate queues for each of my servers. Thanks

Please or to participate in this conversation.