DtcQueueBundle icon indicating copy to clipboard operation
DtcQueueBundle copied to clipboard

Jobs are queued without method name

Open Siba94 opened this issue 6 years ago • 13 comments

Hello,

While my jobs are pushed into the queue, it goes along with null value. Please look into the following snapshot for better understanding. selection_002 selection_003 selection_004

Siba94 avatar Jan 17 '19 06:01 Siba94

Hello @mmucklo please look into this matter asap. I am unable to get why and how this happened. These details are under All jobs tab and my waiting list is empty right now.

Siba94 avatar Jan 17 '19 06:01 Siba94

@Siba94 now im using this proyect for somethings in my work, can you show us the Worker file and the way about you are calling the job?! maybe i can help you

rrcfesc avatar Jan 17 '19 16:01 rrcfesc

Hello @rrcfesc $this->container->get("queue_name")->later(delay_seconds)->methodName(arguments); The above mentioned code I used for creating the jobs. And for processing that jobs I usually run "dtc:queue:run -m no_of_jobs_to_be_processed" inside a cron. selection_005 selection_006 The above snapshots are my worker file code.

Siba94 avatar Jan 17 '19 16:01 Siba94

Hi @Siba94 the code:

$this->container->get("queue_name")->later(delay_seconds)->methodName(arguments);

are you calling from some Controller?

rrcfesc avatar Jan 17 '19 21:01 rrcfesc

Version of Symfony??

rrcfesc avatar Jan 17 '19 21:01 rrcfesc

Hi @rrcfesc Yes, I use that code in a controller as well as in services. symfony version 3.4.

Siba94 avatar Jan 18 '19 05:01 Siba94

Hello, @rrcfesc @mmucklo can you help me on this?

Siba94 avatar Jan 19 '19 07:01 Siba94

@Siba94 , im trying to reproduce that, i have a diferent aproach, but, you can send me the service.yml and how is defined, i have a example how im implement

<?php
/**
 * @author Ricardo Ruiz <[email protected]>
 */
namespace App\Worker;

use Dtc\QueueBundle\Model\Worker;
use MedCore\MedConnector;
use App\Interfaces\CronInterface;
use Psr\Log\LoggerInterface;

/**
 * Class ExternalTranscriptExpiring
 * Used to generate each company
 * @package App\Worker
 * @author Ricardo Ruiz Cruz <[email protected]>
 * @version 0.9
 */
class ExternalTranscriptExpiring extends Worker implements CronInterface
{
   

    /**
     * Adding each company to the JobQueue for the
     * @param string $executeDay Day of execution
     * @throws \MedCore\Exception\ApiException
     * @throws \MedCore\Exception\CurlException
     * @throws \MedCore\Exception\SdkException
     * @throws \Exception
     *
     */
    public function generate($executeDay = '') :void
    {
        echo "asd";
        $start = microtime(true);
        $dateTime = new \DateTime("NOW");
        try {
            if (strlen(trim($executeDay)) === 0) {
                $executeDay = "NOW";
            }
            $dateTime =  new \DateTime($executeDay);
        } catch (\Exception $e) {
            throw new \Exception("No Date configurated");
        }
        $cron = $this->medConector->CronJob->post([
            'description' => 'Master Cron '.$this->resourceName,
            "notification"=> 1,
            "company"=> null,
            "status"=> "progress"
        ]);
        //$i = 1;
        $this->logger->notice("Generating External Transcript Expiring");
        //do {
        $data = $this->medConector->Company()->page(350, array('items'=>5));
        $items = $data['hydra:member'];
        foreach ($items as $item) {
            $this->logger->debug("Adding the next company", $item);
            $this->later(0, 255)->executeCronCompany($item['id'], $dateTime);
        }
        //    $i++;
        //} while(count($items) >0);
        $timeElapsedSecs = microtime(true) - $start;
        $this->medConector->CronJob($cron['id'])->put([
            'description' => $cron['description']." Time executed: ".$timeElapsedSecs,
            'status' => 'success',
        ]);
        $this->logger->notice("Time generated");
    }

    /**
     * Generating the company process independing of the cron, or the date
     * @param integer $companyId
     * @param \DateTime $dateTime
     * @throws \MedCore\Exception\ApiException
     * @throws \MedCore\Exception\CurlException
     */
    public function executeCronCompany($companyId, \DateTime $dateTime) : void
    {
        //echo $companyId."\n";
        $start = microtime(true);
        $cron = $this->medConector->CronJob->post([
            'description' => $this->resourceName." execute Company".$companyId,
            "notification"=> 1,
            "company"=> null,
            "status"=> "progress"
        ]);
        $this->logger->debug("CronData".print_r($cron, true));
        $timeElapsedSecs = microtime(true) - $start;
        $this->medConector->CronJob($cron['id'])->put([
            'description' => $cron['description']." Time executed: ".$timeElapsedSecs,
            'status' => 'success',
        ]);
    }
    /**
     * {@inheritdoc}
     * @return string
     */
    public function getName() :string
    {
        return "ExternalTranscriptExpiring";
    }
}
``

rrcfesc avatar Jan 21 '19 23:01 rrcfesc

Hi @rrcfesc, getting that issue often. Now It is working fine but still, I don't understand how the jobs are queued without a method name. Is it possible? and I have some questions, please help to get through this. Why do we need pruning for regular jobs? Why stalled feature is there and how it will help? As per documentation, it is there to show how to use but did not cover why do we need that. Any kind of help will be appreciated.

Siba94 avatar Jan 22 '19 06:01 Siba94

Hi @rrcfesc @mmucklo Please explain what does it means when jobs are listed as a status "running"? as I am unable to figure out because lack of information or documentation about it and also please provide some documentation about how later and batch later works.

Siba94 avatar Feb 20 '19 10:02 Siba94

@Siba94 sorry for the delay - my hands have been tied for months now - are you still having this issue?

mmucklo avatar Apr 06 '19 02:04 mmucklo

@mmucklo yes, sometimes and also there are jobs with status running in my all jobs section but nothing happened to them for a long time. Can you help me with this? I have a large number of running jobs for a long time. Do not understand why this type of problem occurred.

Siba94 avatar Apr 06 '19 04:04 Siba94

@Siba94 I feel bad - I just saw your response now - if a job is killed or dies in the middle (OOM error, or Segfault, uncaught exception, power reboot, etc.) the job will be stuck in running.

The Running status gets set as soon as the job starts. When a job is finished (without causing a segfault / etc.) the status is supposed to get set to Finished or Error.

If you just want a one-time reset to restart all jobs that are stalled in running, then you can try the reset command.

https://github.com/mmucklo/DtcQueueBundle/blob/master/Command/ResetCommand.php

Otherwise if you just want to remove them from the database, you'll want to periodically use the prune command (as detailed in the README.md).

mmucklo avatar Jul 04 '19 08:07 mmucklo