Description
First of all, thank you for the great packages. They helped me and my team a lot in working with such transports as Kafka and Pub/Sub. I think this library is a must-have for message-oriented PHP app.
This issue follows the issue from queue-interop/queue-interop. In a couple of words, now the body of a message is restricted to string
. From the source code, I can divide transport into three categories (this taxonomy sometimes based only on the current implementation):
string
body:json_encode
'd body:serializable
body:
From what I can see all of the implementations (except amqp
, why read later on) can be made to use serializable
body. It is properly done in rdkafka
, redis
and wamp
: context accepts serializer that is used to serialize/deserialize the message.
The only one that a bit tricky is ampq. You can set the content type of a message in the headers, so it will provide overhead to manage serialization and setting proper content type -- as a user can provide serializer of one type and header of another. This should be validated, that brings some complications, so using a string here is ok, I guess.
Just as a proof of concept I have skipped type hint in interfaces (please, see Sevavietl/queue-interop) and created StringBodyOnlyTrait
to restrict implementation (this breaks LSP, although). Then I have altered enqueue packages to use new interfaces and made tests pass (please, see Sevavietl/enqueue-dev). I can create a PR from my fork if you want, just do not know if my implementation is what you want.
From my point of view, this is a minimal amount of work to provide the ability to use arbitrary body type. But in the long run, I'd improve all packages to use a serializer (again, maybe except amqp).
Thank you in advance.