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

document how to set result data #57

Open
tacman opened this issue Jan 3, 2024 · 1 comment
Open

document how to set result data #57

tacman opened this issue Jan 3, 2024 · 1 comment

Comments

@tacman
Copy link
Contributor

tacman commented Jan 3, 2024

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?


    }
@bobvandevijver
Copy link
Contributor

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!

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

2 participants