Skip to content

Not handling clojure ratio correctly? #2

@tsaixingwei

Description

@tsaixingwei

Clojure ratios are being converted to floating points when sent to and consumed from a JMS queue.

See this simple test code where the ratio 24/7 is converted to 3.428571428571429 when consumed.

(ns jms.test_jms
  (:require [bowerick.jms :as j]))

(def url "tcp://127.0.0.1:61616")

(def destination "/topic/my.test.topic")

(def consumer (j/create-json-consumer
                url
                destination
                (fn [data] (println "Received:" data))))

(def producer (j/create-json-producer url destination))

(producer "foo")
;;=> nil
;Received: foo

(producer '(1 7 0 1))
;;=> nil
;Received: (1 7 0 1)


(producer #{true false #inst"2008-05-10T00:00:00.000-00:00" 33.33M})
;;=> nil
;Received: (true false 2008-05-10T00:00:00Z 33.33)

;; Warning: Note that it does not handle ratios well converting it to floating point instead.
(producer 24/7)
;;=> nil
;Received: 3.428571428571429

(j/close producer)
;;Closing producer: tcp://127.0.0.1:61616 /topic/my.test.topic

(j/close consumer)
;;Closing consumer: tcp://127.0.0.1:61616 /topic/my.test.topic

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions