We have cloud-hosted (RackSpace cloud) Ruby and Java apps that will interact as follows:
We are interested in evaluating both messaging formats (JSON, Buffer Protocols, Thrift, etc.) as well as message transmission channels/techniques (sockets, message queues, RPC, REST, SOAP, etc.)
Our criteria:
What combination of message format and transmission method would you recommend? Why?
I've gathered here some materials we have already collected for review:
We have decided to go with BSON over RabbitMQ.
We like BSON's support for heterogeneous collections and the lack of the need to specify the format of messages up-front. We don't mind that it has poor space usage characteristics and likely poorer serialization performance than other message formats since the messaging portion of our application is not anticipated to be the bottleneck. It doesn't look like a nice Clojure interface has been written to let you directly manipulate BSON objects, but hopefully that won't be an issue. I will revise this entry if we decide that BSON won't work out for us.
We chose RabbitMQ mainly because we already have experience with it and are using it in a system that demands high throughput and availability.
If messaging does become a bottleneck, we will look first to BERT (we rejected it because it currently does not appear to have Java support), then to MessagePack (rejected because it appears that there isn't a large community of Java developers using it), then to Avro (rejected because it requires you to define your message format up-front), then Protocol Buffers (rejected because of the extra code generation step and lack of heterogeneous collections) and then Thrift (rejected for the reasons mentioned for Protocol Buffers).
We may want to go with a plain RPC scheme rather than using a message queue since our messaging style is essentially synchronous point-to-point.
Thanks for your input everyone!
Update: Here is the project.clj
and core.clj
that shows how to convert Clojure maps to BSON and back:
;;;; project.clj (defproject bson-demo "0.0.1" :description "BSON Demo" :dependencies [[org.clojure/clojure "1.2.0"] [org.clojure/clojure-contrib "1.2.0"] [org.mongodb/mongo-java-driver "2.1"]] :dev-dependencies [[swank-clojure "1.3.0-SNAPSHOT"]] :main core) ;;;; core.clj (ns core (:gen-class) (:import [org.bson BasicBSONObject BSONEncoder BSONDecoder])) (defonce *encoder* (BSONEncoder.)) (defonce *decoder* (BSONDecoder.)) ;; XXX Does not accept keyword arguments. Convert clojure.lang.Keyword in map to java.lang.String first. (defn map-to-bson [m] (->> m (BasicBSONObject.) (.encode *encoder*))) (defn bson-to-map [^BasicBSONObject b] (->> (.readObject *decoder* b) (.toMap) (into {}))) (defn -main [] (let [m {"foo" "bar"}] (prn (bson-to-map (map-to-bson m)))))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With