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

Send with json data type #49

Closed
amanformuli opened this issue Sep 2, 2022 · 7 comments · Fixed by #50
Closed

Send with json data type #49

amanformuli opened this issue Sep 2, 2022 · 7 comments · Fixed by #50

Comments

@amanformuli
Copy link

Hi All,

First of all I appreciate your work. Secondly, is it possible to add a separate public method(in Zenstruck\Messenger\Test\Transport\TestTransport) to send with deserialized data so that a JSON data type is passed as parameter?
{
'headers' => [
'type' => 'Class'
],
'body' => '{"serialized":"data}'
}

Thanks

@kbond
Copy link
Member

kbond commented Sep 2, 2022

Hey @amanformuli!

First of all I appreciate your work.

Thank you :)

Secondly, is it possible to add a separate public method...

I guess you mean something like ->sendSerialized(string $data) and the transport decodes this $data before actually calling ->send()?

@amanformuli
Copy link
Author

Hi Kevin,

Indeed I asked for such method with only one thing: is it possible to keep the $data type as an array so that both the headers and body of the message is passed. If the send method does not do anything with the headers, then string $data would be fine.

Thanks

@kbond
Copy link
Member

kbond commented Sep 2, 2022

is it possible to keep the $data type as an array

I will need to use the transport's configured serializer to decode the message - this does indeed require an array (I thought it was a string) so yes, sendSerialized() should be able to take an array.

@kbond
Copy link
Member

kbond commented Sep 2, 2022

BTW, can you describe your use case for this? I don't think it's invalid, I'd like to describe why you'd do this in the docs for this feature.

@amanformuli
Copy link
Author

Actually I am using symfony serializer(configured to my symfony messenger) and wanted to test the message with json format instead of Object class.

@kbond
Copy link
Member

kbond commented Sep 2, 2022

Got it, would it be valuable to for TestTransport::send() to accept a json string in addition to a decoded json array?

@amanformuli
Copy link
Author

Yeah that is also fine to accept a json string.

@kbond kbond closed this as completed in #50 Sep 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants