Hot answers tagged

6

The answers to your questions will inevitably be, that it depends, however I have tried to present examples of situations that may help clarify things a bit further. Does creating a single job with 10,000 steps use more resources than creating 100 jobs with 100 steps? Each queue job is stored as a row in the queue database table. If a job had 10,...


5

To reiterate what has been said in the comments above and to present an answer, the best way to ensure that queue jobs are completed even without the CMS being logged into or the site being visited is using a scheduled cron job. The following will run all jobs in the queue every 10 minutes: */10 * * * * /usr/bin/php /path/to/craft queue/run


4

So if you're running the queue jobs via one of the techniques outlined in the Robust queue job handling in Craft CMS article, it shouldn't matter. But I'm guessing you're doing this in the context of a plugin, where you can't control what setup the user has for executing their queue jobs. In that case, I'd opt for breaking it up into smaller queue jobs ...


2

The easiest solution for this would be either a special fieldvalue or a property in a behavior that you set in your job. class MyJob extends BaseJob { public function execute($queue): bool { // do some api calls here // .... $entry->isSavedViaApi = true; $entry->setFieldValue('browsershotUrl', [$assetId]); ...


2

Make sure that "run queue" is set in general.php also! <?php ... return [ ... '*' => [ 'runQueueAutomatically' => true, ] ]


2

You can set the runQueueAutomatically config setting to false to prevent this. You'll just want to set up an alternative way to process the queue as noted in the docs.


2

"How does X work?" is a very broad question, and not one I intend to try and answer in detail here. Below are a few resources that should help get you started: Robust queue job handling in Craft CMS How to best design large queue jobs? Also, here are all questions tagged with queue: https://craftcms.stackexchange.com/questions/tagged/queue Hope ...


2

Ok so with these the trick is to look for anything that might involve a request session, which is not available when you're running things via a console request. In this case there's at least one obvious suspect line: Craft::$app->session->setError('Lightspeed....); Indeed there's more than one of these. It's basically the same problem as previously - ...


2

I think this is a Symfony error for when the server kills your PHP process. Could be a timeout or exhaustion of RAM. Are you using the Craft Async Queue plugin? It offloads these jobs to the PHP CLI to run in the background and lets you get around timeouts and jamming your site up. I'd tail or grep through both your Craft error logs and Apache logs for hints ...


2

Yes, you can pass through the customer ID to your queue job, then the job itself can look up the customer and send the email. Here's a super-simple example console controller action method that passes through a user ID to a queue job class called SendEmail: public function actionSend() { $userIds = User::find() ->status(User::STATUS_ACTIVE) ...


2

Class 'modules\importGeoJson\BaseJob' not found You're getting this error because you're trying to extend the craft\queue\BaseJob, but you're not importing (aliasing) that class. In general, a simple class identifier will be assumed to belong to the current namespace. So since your class is namespaced to modules\jobs, the BaseJob class identifier resolves ...


2

I'm going to lay out the answer here, in case someone else runs into someone else's issue. We are using Postmark to process emails. All of the failures in the queue are email addresses that have previously hard bounced in postmark. The reason it's always the shipping confirmation email has nothing to do with the shipping confirmation email, but the fact that ...


2

queue/run - should be used if you're going to manually execute this command via a cron job or such, because it runs any pending queue jobs, then exits queue/listen - should be used if you want it to constantly poll (with a reasonable cooldown interval) for new jobs, and run them, because it runs a listen process that spawns a sub-process to run queue jobs as ...


1

Yes, you can access the queue component using \Craft::$app->getQueue(). Keep in mind that this may return null or a non-compatible component depending on configuration, so make sure to check if the queue component is an instance of the craft\queue\QueueInterface. The default queue component (craft\queue\Queue) has all the methods you need to build your ...


1

For anyone strugglng with this. I split the process into a service and a job. It seems you also have to register your job/services classes in main plugin file first: $this->setComponents([ 'Importgeojson' => Importgeojson::class, // job 'MapitapiService' => MapitapiService::class // service ]); then call the service ...


1

It sounds like you have either an order issue or a queue issue. What happens if you try to send that specific email from the order's edit screen? If it's a Twig/order email / syntax problem, you'll get an error. It sounds like you may have already tried this but when you preview an email from Commerce -> Store Settings -> Emails, you're previewing a ...


1

I wanted to post a follow-up in case anyone else encounters a similar error. It appears the error itself is being reported by a Symfony library. But what it's reporting (in the case of a signal 9 error) is that the process was terminated via SIGKILL. The reason for this could be any number of things. To troubleshoot further I ran some after-hours tests with ...


1

Fixed this by adding return [ 'modules' => [ 'my-module' => \modules\Module::class, ], 'components' => [ 'queue' => [ 'ttr' => 3600, ], ], ]; to config/app.php.


1

The priority option is for setting the jobs in priority order before they start. A job that is already running will not be interrupted for a more important one. I would suggest setting up another queue for the longer tasks. That way, your smaller tasks can continue to run separate to the more demanding ones. There is some guidance on how to do this on an ...


1

You can try disabling Craft's queue temporarily by adding 'runQueueAutomatically' => false to general.php, then trigger the feed via the command line. Without testing this might prevent the 'Updating element slugs and URIs' job, but in any case – doing it this way you should see better performance overall. p.s. if you add --verbose to the end of the ...


1

This is a gotcha with the recent move to emails being sent by the queue and not during the actual checkout process. Your problem is this line (and other lines you might have like it...): variant.salePrice|commerceCurrency(craft.commerce.carts.cart.currency) ...when the queue runs, there is no current cart for the commerce carts service to retrieve, so ...


1

Turns out the answer in my case is to use a JSON data source. Importing users as .json instead of .csv appears to be about 10 times faster: With .csv importing 480 users took 2.5 hours With .json importing 455 users took 15 minutes My JSON looked like this: {"user": [ { "username":"jane.doe@example.com", "email":"jane.doe@example....


1

You will need to investigate the log files to determine the source of the problem. There should be a storage/logs/queue.log file. This article might be helpful https://nystudio107.com/blog/zen-and-the-art-of-craft-cms-log-file-reading


1

I found a solution. In my control panel module javascript, I can do Craft.cp.on('setJobInfo', function(e){ console.log(e); });


1

Update the Notifications plugin. From Craft Support: Ultimately Yii/Craft is using PHP's serialize() method to do the serialization, which has always had quirks with serializing different types of objects, especially the more complex those objects are. We try to only serialize simple objects and primitive data structures (arrays, strings, ...


Only top voted, non community-wiki answers of a minimum length are eligible