Previously clojurewerkz.machine-head.client/subscribe accepted
a list of topics and optionally a list of QoS levels:
(mh/subscribe c ["mh/topics/#" "mh/alt.topics/+"]
(fn [^String topic meta ^bytes payload])
{:qos [0 1]})This turns out to be a fairly confusing API.
We've changed it to accept a map of topics to QoS levels. While a bit more verbose, this API make it very clear what topic will use what QoS:
(mh/subscribe c {"mh/topics/#" 0 "mh/alt.topics/+" 1}
(fn [^String topic meta ^bytes payload] ))The project now depends on org.clojure/clojure version 1.6.0. It is
still compatible with Clojure 1.4 and if your project.clj depends on
a different version, it will be used, but 1.6 is the default now.
We encourage all users to upgrade to 1.6, it is a drop-in replacement for the majority of projects out there.
When publishing, retain now defaults to false,
which is a much more sensible default.
Contributed by Martin Trojer.
It is now possible to set :clean-session to `false.
Contributed by Martin Trojer.
Machine Head now supports providing client last will and testament:
(require '[clojurewerkz.machine-head.client :as mh])
(let [will {:topic "lw-topic" :payload (.getBytes "last will") :qos 0 :retain false}]
(mh/connect "" (mh/generate-id) {:will will}))Contributed by Paul Bellamy.
MQTT spec dictates that client ID's should be limited to 23 bytes. Eclipse Paho client generator can produce ID's longer than that.
Machine Head now will limit ID length to the last 23 bytes.
Contributed by Yodit Stanton.
clojurewerkz.machine-head.client/connect now supports one more
option: :clean-session. When set to true, the option means that
the client and MQTT broker should discard state that might have
been kept from earlier connections.
clojurewerkz.machine-head.client/subscribe-with-qos is removed. Instead,
clojurewerkz.machine-head.client/subscribe now takes a new option, :qos.
Contributed by Martin Trojer.
clojurewerkz.machine-head.client/disconnect-and-close is a new function that's
identical to clojurewerkz.machine-head.client/disconnect but also releases
all resources used by the client (e.g. file descriptors used by durable write-ahead
log).
clojurewerkz.machine-head.client/publish now also accepts MqttMessage instances
that makes it easy to republish pending messages returned by clojurewerkz.machine-head.client/pending-messages.
clojurewerkz.machine-head.client/pending-messages is
a new function that is similar to clojurewerkz.machine-head.client/pending-delivery-tokens
but returns messages instead of delivery tokens (identifiers). It returns
a lazy sequence.
The sequence can only be non-empty if client terminated before finishing delivering all previously published messages.
clojurewerkz.machine-head.client/pending-delivery-tokens is
a new function that takes a client and returns a collection of
pending delivery tokens. The collection can only be non-empty
if client terminated before finishing delivering all previously
published messages.
Machine Head beta1 supports connecting to MQTT brokers
(tested against Mosquitto and RabbitMQ MQTT plugin),
topic subscriptions and publishing.
The API is a subject to change at any time.