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.