private String retainTestSetup(boolean isRetained, MsgGenerator mgen) throws Exception {
Topology top = newTopology("retainTestSetup"+isRetained);
int qos = 0;
String clientId = newClientId(top.getName());
String topic = getMqttTopics()[0];
String retainedMsg = mgen.create(topic, isRetained ? "RETAIN-THIS" : "DO-NOT-RETAIN-THIS");
MqttConfig config = newConfig(getServerURI(), clientId+"-setup");
MqttStreams mqtt = new MqttStreams(top, () -> config);
TStream<String> s = PlumbingStreams.blockingOneShotDelay(
top.strings(retainedMsg), PUB_DELAY_MSEC, TimeUnit.MILLISECONDS);
mqtt.publish(s, topic, qos, isRetained);
TStream<String> rcvd = mqtt.subscribe(topic, qos);
completeAndValidate(clientId, top, rcvd, mgen, SEC_TIMEOUT, retainedMsg);
return retainedMsg;
}