Really Small Message Broker as a Service

Earlier today I mentioned that I was playing with the IBM Really Small Message Broker (RSMB) and that’s working fine but then it occurred to me that having it on the desktop is not the smartest thing to do. Really it needs to be a service – however as that isn’t one of it’s options, I went off in search of ways to “make it so”.

This article describes how to make any program into a service and here is the binary to do just that.  So basically I took their program wins-1.16-bin.exe and renamed it to mymqtt.exe as they suggested we give them meaningful names. I put it in the same directory as my RSMB. It needs an XML file (simple text file) of the same name to tell it what the name of the service will be – and where the executable will be. Here’s what I put in.

<service>
  <id>mqtt</id>
  <name>Really Simple Message Broker</name>
  <description>Really Simple Message Broker</description>
  <executable>c:\users\pete\desktop\really_small_broker\windows\broker.exe</executable>
  <startargument>broker.cfg</startargument>
  <stopargument>stop</stopargument>
</service>

I then ran the following…

mymqqt.exe install

mymqtt.exe start

And LO – a service.

tmpF805

 

 

Ok, stop and uninstall don’t seem to work but I don’t really need that anyway – I CAN say for sure that the program starts up automatically on on power cycle without any visual interface  –   I suspect the stop argument is rubbish…

Advertisements

2 thoughts on “Really Small Message Broker as a Service

  1. I used NSSM (nssm.cc) to automatically launch the MQQT broker (and a couple of other things). Start/Stop/Restart appear to work fine – haven’t tried uninstalling).

    Looking forward to more updates on the ESP8266 – I was able to use one of mine to get an Arduino talking to the MQQT broker vi serial AT commands to the ESP8266. Using it without the Arduino is on my todo list.

  2. As a follow up I have to say that service did not auto start on Windows 8 at all – but thanks to another reader I’m now using NSSM http://nssm.cc/

    That works – though when I tried to START the service with it’s command line option – it had some permissions issue so I did it through the normal Windows services start – called my service “broker” – told it to retry if it failed. Works a treat, sits in the background with no visible interface, restarts with Windows. At the same time I discovered that MQTT-SPY https://code.google.com/p/mqtt-spy/ can autoconnect and autosubscribe (it just doesn’t do it by default).

    All good stuff – so thats’ Really Small Message Broker as a service with QOS0-2 and retain – and a decent client to play with – I had some minor issues with mqtt-spy and I have to say the designer came straight back and added my suggestion to the list. Excellent.

    The MQTT software works – https://github.com/tuanpmt/esp_mqtt
    If you used the original you should be aware that there are now 2 files you need to mess with – user_config.h and user_main.c – and in user_config.h you need to change this variable when you make any changes..

    Change value of CFG_HOLDER when you change default configuration. He uses this to update FLASH with details to speed up logging in.

    Also if you don’t use an SSL broker, please change security mode to SEC_NONSSL: This is in
    MQTT_InitConnection(&mqttClient, sysCfg.mqtt_host, sysCfg.mqtt_port, SEC_NONSSL);

    The above is in user_main around line 77 – just change that constant.from SEC_SSL to SEC_NONSSL

    Finally when you do send a message, at THIS time you’ll see a strange result which I’ve asked him to fix

    to “/test//topic” I sent “hmm”

    The response was…

    MQTT topic: /test/topichmm, data: hmm

    Just some replication there, I’m sure that’ll get fixed… it’s now quite easy in user_main to put any wrapper around the data you want..

    void mqttDataCb(uint32_t *args, const char* topic, uint32_t topic_len, const char *data, uint32_t length)
    {
    INFO(“MQTT topic: %s, data: %s \r\n”, topic, data);
    }

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s