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

Do payloads have to be JSON? #56

Closed
Xachman opened this issue Jul 1, 2020 · 8 comments
Closed

Do payloads have to be JSON? #56

Xachman opened this issue Jul 1, 2020 · 8 comments

Comments

@Xachman
Copy link

Xachman commented Jul 1, 2020

In the Queue\Job class it uses the payload function from \Illuminate\Queue\Jobs\Job. This function returns json and if the payload in rabbitmq is not json it returns null. When this happens you will get a too few arguments error on your listener classes handle function.

If its expected that we will always be using json can we add that to the documentation? Otherwise we should implement this so other none json data can be stored and passed along.

@masterjus
Copy link
Contributor

@Xachman you're right, json is required format. I'll add this requirement to documentation and think how to validate payload.

@masterjus
Copy link
Contributor

masterjus commented Jul 6, 2020

@Xachman one question: when you publish data, you need to pass a php array to publish method and this method converts an array to json inside. How it happened that nonjson data was published?

@Xachman
Copy link
Author

Xachman commented Jul 6, 2020

The other service is not laravel. I was just publishing messages for testing. The frontend application is laravel and the backend will be python consuming messages from the laravel application and publishing other messages. Knowing the expected format here is important so these 2 applications can communicate.

@masterjus
Copy link
Contributor

masterjus commented Jul 6, 2020

OK. The package expects that messages are published and handled by their methods, so your flow didn't expected.

Please suggest the best part of doc where I should add notice about format and I'll add it.

@Xachman
Copy link
Author

Xachman commented Jul 6, 2020

I think in the listeners section it should be noted since this is where it applies and will fail.
https://github.com/nuwber/rabbitevents#defining-listeners-

In my tests what would happen is the payload was not even passed in if it was not json. You get the 1 argument expected none passed in error. So its not really clear here what the expectation is of the Listener payload is just that it's usually an array. Tho I cant see what case it would not be an array since it's using the type in the parameter.

@masterjus
Copy link
Contributor

masterjus commented Jul 7, 2020

@Xachman The documentation has been updated. Is it clear now?

@Xachman
Copy link
Author

Xachman commented Jul 7, 2020

This definitely helps! I think this information on how payloads are interpolated is beneficial even in a standard use case. I'm not going to be too picky about this tho my project is working knowing that the expected format is json.

@masterjus
Copy link
Contributor

Ok, thank you for your help. I close the issue.

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