DtcQueueBundle
DtcQueueBundle copied to clipboard
Jobs are queued without method name
Hello,
While my jobs are pushed into the queue, it goes along with null value. Please look into the following snapshot for better understanding.
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 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
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.
The above snapshots are my worker file code.
Hi @Siba94 the code:
$this->container->get("queue_name")->later(delay_seconds)->methodName(arguments);
are you calling from some Controller?
Version of Symfony??
Hi @rrcfesc Yes, I use that code in a controller as well as in services. symfony version 3.4.
Hello, @rrcfesc @mmucklo can you help me on this?
@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";
}
}
``
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.
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 sorry for the delay - my hands have been tied for months now - are you still having this issue?
@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 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).