-
Notifications
You must be signed in to change notification settings - Fork 45
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
Consider providing serialization-aware consumer API #6
Comments
yes, and clojure data structure (de)serialization: (defn serialize [data]
(binding [*print-dup* true] (pr-str data)))
(defn deserialize [str]
(with-in-str str (read)) suggested content-type: |
https://github.com/mefesto/wabbitmq has generic serialization support, could be worth checking out.. |
maybe even include content-encoding, eg. automatic gzip (de)compression of payloads.. |
I've written my own abstraction on top that uses a ring style to attach additional behaviors like this. So I have a wrap-decode-payload wrapper that support JSON or EDN based on content-type. Similarly, I have a wrap-encode-payload for going the other way and several other wrappers for other purposes. Gzip could be supported the same way. This pattern seems to work pretty well. |
@mlimotte yes, I was contemplating doing just that. |
Has the release of transit any incidence over this discussion? |
Transit doesn't change anything for us. We can't support a single transport only. |
OK. Thanks. Just to be clear: is it up to everyone to build their abstractions on top of langohr for serialization/deserialization, or are there features/best practices/examples that can help when starting out? |
Well, if you can deserialize a byte array in your consumer, you are all set today. We can provide a protocol and a deserializing consumer function that will do it for you and call your handler with a Clojure data structure, that's pretty much it. |
Thanks, Michael, I'll take the first suggestion for now. Coming from Ruby, I'm always surprised when there's no native data structures straight off the box. |
Many scenarios in message consumer applications are very common. For example, JSON or MsgPack used for serialization. We should investigate a convenient way to plug common serialization formats into consumer API. Then
payload
attribute can be a data structure instead of a bag of bytes.The text was updated successfully, but these errors were encountered: