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

Jobs are queued without method name #100

Open
Siba94 opened this issue Jan 17, 2019 · 13 comments
Open

Jobs are queued without method name #100

Siba94 opened this issue Jan 17, 2019 · 13 comments

Comments

@Siba94
Copy link

Siba94 commented Jan 17, 2019

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
Copy link
Author

Siba94 commented Jan 17, 2019

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.

@rrcfesc
Copy link

rrcfesc commented Jan 17, 2019

@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

@Siba94
Copy link
Author

Siba94 commented Jan 17, 2019

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.

@rrcfesc
Copy link

rrcfesc commented Jan 17, 2019

Hi @Siba94 the code:

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

are you calling from some Controller?

@rrcfesc
Copy link

rrcfesc commented Jan 17, 2019

Version of Symfony??

@Siba94
Copy link
Author

Siba94 commented Jan 18, 2019

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

@Siba94
Copy link
Author

Siba94 commented Jan 19, 2019

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

@rrcfesc
Copy link

rrcfesc commented Jan 21, 2019

@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";
    }
}
``

@Siba94
Copy link
Author

Siba94 commented Jan 22, 2019

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
Copy link
Author

Siba94 commented Feb 20, 2019

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.

@mmucklo
Copy link
Owner

mmucklo commented Apr 6, 2019

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

@Siba94
Copy link
Author

Siba94 commented Apr 6, 2019

@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.

@mmucklo
Copy link
Owner

mmucklo commented Jul 4, 2019

@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).

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

3 participants