Service Virtualization

  • 1.  Does DevTest support pub/sub for MQTT?

    Posted Jul 31, 2018 03:26 PM

    Hello All,

     

    Please let me know if there is an existing step for subscribing/publishing messages from/to MQTT?



  • 2.  Re: Does DevTest support pub/sub for MQTT?
    Best Answer

    Broadcom Employee
    Posted Aug 01, 2018 12:16 AM

    Hi Tushar,

     

    By checking the manuals for the current version 10.3, there are not any explanation about MQTT.
    Then I think there is not an existing step for subscribing/publishing messages from/to MQTT.

     

    Thank you,



  • 3.  Re: Does DevTest support pub/sub for MQTT?

    Posted Aug 01, 2018 02:02 PM

    Okay. Thanks!



  • 4.  Re: Does DevTest support pub/sub for MQTT?

    Broadcom Employee
    Posted Aug 02, 2018 05:22 AM

    Hi Tushar,

     

    you might be able to circumvent this by using an ActiveMQ broker and using JMS/ActiveMQ steps. See Apache ActiveMQ ™ -- MQTT . Yusuke is right in that we do not support MQTT directly right now.



  • 5.  Re: Does DevTest support pub/sub for MQTT?

    Broadcom Employee
    Posted Aug 02, 2018 10:51 AM

    We've been discussing MQTT internally for a long time, and there's even an outstanding idea on this community about it DevTest Test and Virtualization support for MQTT  but there doesn't appear to have been much traction yet.

     

    I have a personal interest, using MQTT at home, and so I added the Apache Paho MQTT client JAR from Index of /repositories/paho-releases/org/eclipse/paho/mqtt-client/0.4.0  to the DevTest hotDeploy directory. When I'd done that, I created a new test, and inserted a scripting step into it. I pasted the Paho sample for publishing a message from Eclipse Paho - MQTT and MQTT-SN software  (changing logging lines as necessary), and it works perfectly.

     

    The sample I pasted is this:

    import org.eclipse.paho.client.mqttv3.MqttClient;
    import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
    import org.eclipse.paho.client.mqttv3.MqttException;
    import org.eclipse.paho.client.mqttv3.MqttMessage;
    import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;

     

    String topic = "MQTT Examples";
    String content = "Message from MqttPublishSample";
    int qos = 2;
    String broker = "tcp://my_MQTT_hostname:1883";
    String clientId = "JavaSample";
    MemoryPersistence persistence = new MemoryPersistence();

     

    MqttClient sampleClient = new MqttClient(broker, clientId, persistence);
    MqttConnectOptions connOpts = new MqttConnectOptions();
    connOpts.setCleanSession(true);
    _logger.info("Connecting to broker: {}",broker);
    sampleClient.connect(connOpts);
    _logger.info("Connected");
    _logger.info("Publishing message: {}",content);
    MqttMessage message = new MqttMessage(content.getBytes());
    message.setQos(qos);
    sampleClient.publish(topic, message);
    _logger.info("Message published");
    sampleClient.disconnect();
    _logger.info("Disconnected");
    return "Message sent";

     

    Because I found it this straightforward, it would be just as simple to create a simple subscriber in a script.

     

    If I do this, it's not much more work to create a VSM containing it. That VSM would then use half-bridging (see Service Virtualization using half-bridging (TIBCO Rendezvous) ) so we can record and deploy MQTT virtual services.

     

    I suppose I could create this, for use unless / until we receive a critical mass of requests to productise MQTT support.



  • 6.  Re: Does DevTest support pub/sub for MQTT?

    Posted Aug 02, 2018 11:59 AM

    I ended up doing the same thing Rick. But this definately helps. Thanks a ton !