Category Archives: Uncategorized

Mule MQTT Connector v0.2 Final Released!

It’s with great pleasure that I introduce Mule MQTT Connector v0.2!!!  Not a lot of changes since v0.1, except for some nice-to-have features that I felt were necessary.  

In this release, there are two major changes that should make this connector a bit more usable by many in the community.  These two changes were:

  • <mqtt:subscribe> now contains a “filter” attribute.  Instead of setting “topicName”, one can simply set the topic filter they’d like to use.  When messages are received that match the filter, Mule simply sets all the appropriate OUTBOUND headers, one being the “”, so you can do routing in Mule based on where it was received.  An example of a topic filter is “sample/#”, which matches “sample/foo” or “sample/bar”, etc.  
  • <mqtt:publish> no longer only takes a java.lang.String payload-only.  You can now simply omit setting the “message” attribute of the publish call, and whatever the current MuleMessage payload is will be converted into a byte[].  Warning:  “message” takes precedence over the MuleMessage payload if set.

I also did some code cleanup, documentation cleanup, etc.  I anticipate new graphics in the near future (for Mule Studio) and submission to MuleForge very soon.  Follow my blog, as I’ll be posting a HOWTO for installation and use of the connector soon as well. 

Thanks for the outpouring of interest and support for this!! 

Code:  (tagged as “v0.2-final”)



Fixes Released, v0.1 FINAL is out!

Tonight I released the final version 0.1 build.  I added a couple nice-to-have’s to this build, including:

  • Full support for the LWT portion of MQTT protocol.  (this is all configurable on the <mqtt:config /> tag). 
  • Change to get rid of the MuleMqttMessage object, and instead return the byte[] payload of a message, with relative information stored in the INBOUND property scope.  I also modified the publish method to appropriately set the OUTBOUND scope accordingly.
  • Fixes to a couple bugs, mainly with Mule application reloading, so that clients appropriately disconnect/reconnect with the MQTT broker. 

You’ll notice I stripped out my functional test cases, and this was due to improper coding of them on my part.  I’m going to re-introduce proper test cases in my upcoming version, 0.2, hopefully.  


MQTT, Mosquitto, Apple and Java Issues

As I develop my Mule connector for MQTT, I ran into some issues that kept me from testing real-world scenarios from my Apple laptop and desktop.  Anytime I connect using the Eclipse Paho MqttClient class, and subscribe to a given topic, I will inevitably get a “Connection Lost” exception after two to four minutes of time.  I mitigate this in my Mule connector by auto-reconnecting to the MQTT broker, however, I was baffled at why this was happening.

I started by running the Sample class provided by the Eclipse Paho team.  I pointed this at my local instance of Mosquitto (installed via Homebrew), and subscribed to a topic.  I simply let the program run without publishing any messages to the broker.  After roughly two minutes, I would get disconnected.  Figuring my configuration of Mosquitto was to blame, I pointed this at the public test Mosquitto server, found at  Again, I repeated the same steps with the same results, an exception was generated minutes later for Connection Lost.

Finally, I pointed the Sample class at a different broker all together, which in this case was the public broker.  Same topic subscription and M.O, I connected and subscribed, and waited.  Thirty minutes passed without a single “connection lost” exception.  To hopefully prove network issues, I re-pointed the program at, and again found myself getting bounced in a couple minutes.

I’m at a loss for the cause of this issue, other then something with Mac’s implementation of Java and Mosquitto.  I even tested this using the Oracle Java7 version for Mac, and found the same issue.  Simply changing the broker implementation fixed it, though I can’t believe that’s the issue’s core.

Running this same code against any Mosquitto broker instance from an Ubuntu Server installation has absolutely no issue.  I’ve reproduced this issue only on Apple computers, currently an Apple iMac running Lion and an Apple MacBook Pro running Mountain Lion.

Please tell me that someone has had similar issues and knows how to fix them?  Or can give me something else to try?  I’ve posted the links to the code that I ran to test this below.