Skip to content

Conversation

@jvangestel
Copy link
Contributor

Add batched messaging support, to track and chain message queue messages.
In RunCommJob chaining messages is required when async processing is turned on, or the execution order will not be correct.
This does lose the interactive console logging during the run, only after every job is complete will it report.

$batch = $batchRepository->getBatch($stamp->batchId);
$batchRepository->setIterationStatus($stamp->batchId, $stamp->iteration, BatchStatus::SUCCESS, $message);

if ($batch->isChain) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jvangestel Wat gebeurt er met een chained batch als de eerste uit de chain faalt? De eerste krijgt dan status failed, maar alle die daar na komen blijven staan op pending? Komen die later nog door? Worden ze ooit opgeruimd?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rvm-peercode Wanneer het gaat om een chain (een voor een) wordt de rest van de chain nu ook op failed gezet.

try {
return $serializer->deserialize($data['gba_message'], $data['gba_message_class'], 'json');
} catch(Exception $e) {
return null;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moet hier niet nog iets gelogd worden?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dit wordt nu gelogged in de info Kolom van de iteratie, incl een failure status


public function getBatch(string $batchId): Batch|null
{
$data = $this->resultFetcher->fetchRow('SELECT * FROM gems__batch WHERE gba_id = ?', [$batchId]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Volgens mij kun je hier meerdere records terugkrijgen (alle iterations). Dus ik zou in elk geval een ORDER BY toevoegen zodat je zeker weet welke je terugkrijgt, en misschien een opmerking in de docblock dat dat by design is.
-> Je gebruikt uiteindelijk ook de status en finished kolommen, maar die zullen niet voor elke iteration gelijk zijn.
Wat hoort dit terug te geven als de eerste iteration al wel gefinished is, maar de tweede niet?

Misschien specifiek de eerste of laatste iteration pakken?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ik heb dit (incl de hele batch object) een algemenere query van gemaakt met statistieken van de hele batch. Deze geldt dan alleen voor de batchId, en niet meer specifiek voor een iteratie

$batchId,
BatchStatus::PENDING->value,
]) > 0;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Omdat je meerdere iterations kunt hebben kan het met de isPending() en isRunning() dus voorkomen dat beiden waar zijn. Ik heb het gebruik van de iterations nog niet helemaal helder, maar om dit expliciet te maken zou ik ofwel alleen kijken naar de status van de laatste iteration, of, als het normaal is dat er meerdere iterations zijn, de functienamen hernoemen naar hasPending() en hasRunning().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aangepast naar hasPending, maar isRunning is logischer voor een hele batch.


public function setIterationFinished(string $batchId, int $iteration, string|null $message = null): void
{
$this->resultFetcher->updateTable('gems__batch', [
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deze function body zou ik vervangen door een aanroep naar setIterationStatus()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Helemaal uit de store gehaald. Aangepast in de MessengerBatchRepository

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

Successfully merging this pull request may close these issues.

3 participants