messenger-monitor-bundle icon indicating copy to clipboard operation
messenger-monitor-bundle copied to clipboard

document how to set result data

Open tacman opened this issue 1 year ago • 1 comments

How do I set result data?

image

My handler

    public function __invoke(FetchWikidataMessage $message)
    {
        $id = $message->getWikidataId();
        $wikiData = $this->wikiService->fetchWikidataPage($id);
        $official = $this->entityManager->getRepository(Official::class)->findOneBy(['wikidataId' => $id]);
        $official->setWikiData($wikiData);
        $this->entityManager->flush();;
        
        // set results for the message monitor?
        return $wikiData; // nope
       // use the logger?


    }

tacman avatar Jan 03 '24 18:01 tacman

You can find the implementation here: https://github.com/zenstruck/messenger-monitor-bundle/blob/1.x/src/History/ResultNormalizer.php

In other words, there are a couple of special handlers, and anything else is handled as a string. Note that if you are returning an object, the recorded data will be null. If you return an array, all scalar values will be used, datetime object converted to a string, and all other stuff to its debug type.

Don't forget to restart the workers after changes!

bobvandevijver avatar Mar 18 '24 20:03 bobvandevijver