JMSJobQueueBundle | Schedule Symfony Console Commands as Background | Cron Utils library
kandi X-RAY | JMSJobQueueBundle Summary
kandi X-RAY | JMSJobQueueBundle Summary
Run and Schedule Symfony Console Commands as Background Jobs
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Close a job
- Check the running jobs
- List job s statistics
- Set the state .
- Initialize the related entities .
- Acquires a cron job lock .
- Find expired jobs .
- Post persist related entities .
- Get the configuration tree builder .
- On tick
JMSJobQueueBundle Key Features
JMSJobQueueBundle Examples and Code Snippets
Community Discussions
Trending Discussions on JMSJobQueueBundle
QUESTION
I have recently moved my Symfony Project to Elastic Beanstalk, from a manually scaling EC2 environment, and i have stumbled on to an issue.
I have a Cron job that grabs a bunch of subscriptions that are past due, and attempts to create orders and charge them, it is very important that this job only runs on a single server cause it grabs them in a batch, if there is a duplicate Cron running, it will lead to multiple charges on the same subscriptions.
In the manually scaling environment, I just had a primary server, that had a crontab and ran the subs, but that does not seem doable here.
Any suggestions on how to set this up in a auto-scaling enviroment with no primary server?
I have looked into JMSJobQueueBundle, but it also seems to rely on supervisor only running a single instance of the crontab, this would be duplicate in an auto scaling environment.
Is my best bet to have an external server ping my API every X minutes and launch the job on the single instance it pings? This seems to introduce another point of failure.
...ANSWER
Answered 2017-Feb-24 at 07:54Just as a warning, the problem you are trying to solve is not a trivial one.
A few options:
If you connect to a MySQL database, acquire a lock (https://dev.mysql.com/doc/refman/5.7/en/miscellaneous-functions.html#function_get-lock) at the beginning of the transaction and release the lock at the end. this will prevent multiple cronjobs to run the code at the same time. works only if everything is handled inside SQL.
As you mentioned, you can use AWS Lambda + CloudWatch Events to trigger a Lambda function every x minutes and the Lambda can than trigger your script via http(s). But lambda does not guarantee that is does so exactly once, so this is not safe.
Use a service where you can acquire a distributed lock (e.g. etcd, consul, redis, ...) and implement in a similar way than 1 just not in your MySQL database. Still you can nor really enfore exactly once with this.
put the cronjob on a separate ec2 instance where you know that it exsists only once (in case of this ec2 instance goes down nothing will run, but as far as I understand your requirements this is not a problem because the script can run 15 minutes later and still catches up with all the work.
The more "modern" approach in distributed systems would be to make your action idempotent.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install JMSJobQueueBundle
PHP requires the Visual C runtime (CRT). The Microsoft Visual C++ Redistributable for Visual Studio 2019 is suitable for all these PHP versions, see visualstudio.microsoft.com. You MUST download the x86 CRT for PHP x86 builds and the x64 CRT for PHP x64 builds. The CRT installer supports the /quiet and /norestart command-line switches, so you can also script it.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page