@Override public MqttConfig get() { ++getCnt; System.err.println("**** getCnt:"+getCnt); // delay enough to induce multiple retry w/o exceeding test harness timeout if (getCnt == 4) pubConfig.setServerURLs(new String[]{ goodServerURI }); return pubConfig; } });
@Override public MqttConfig get() { ++getCnt; System.err.println("**** getCnt:"+getCnt); // delay enough to induce retry w/o exceeding test harness timeout // or missing published tuples if (getCnt == 4) subConfig.setServerURLs(new String[]{ goodServerURI }); return subConfig; } });
/** * Create a connector to the specified server. * <p> * A convenience function. * Connecting to the server occurs after the * topology is submitted for execution. * * @param topology the connector's associated {@code Topology}. * @param url URL of MQTT server. * @param clientId the connector's MQTT clientId. auto-generated if null. */ public MqttStreams(Topology topology, String url, String clientId) { this.topology = topology; MqttConfig config = new MqttConfig(); config.setServerURLs(new String[] {url}); config.setClientId(clientId); connector = new MqttConnector(() -> config); }
val -> config.setPersistence(newPersistenceProvider(val))); setConfig(p, "mqtt.serverURLs", val -> config.setServerURLs(val.trim().split(","))); setConfig(p, "mqtt.subscriberIdleReconnectIntervalSec", val -> config.setSubscriberIdleReconnectInterval(Integer.valueOf(val)));
@Test public void testMultipleServerURL() throws Exception { Topology top = newTopology("testMultipleServerURL"); MsgGenerator mgen = new MsgGenerator(top.getName()); int qos = 0; boolean retain = false; String clientId = newClientId(top.getName()); String topic = getMqttTopics()[0]; List<String> msgs = createMsgs(mgen, topic, getMsg1(), getMsg2()); TStream<String> s = PlumbingStreams.blockingOneShotDelay( top.collection(msgs), PUB_DELAY_MSEC, TimeUnit.MILLISECONDS); // Test server URL selection - supply a bogus 1st URL. String[] serverURLs = new String[] {"tcp://localhost:31999", getServerURI()}; MqttConfig config = newConfig(serverURLs[0], clientId); config.setServerURLs(serverURLs); MqttStreams mqtt = new MqttStreams(top, () -> config); mqtt.publish(s, topic, qos, retain); TStream<String> rcvd = mqtt.subscribe(topic, qos); completeAndValidate(clientId, top, rcvd, mgen, SEC_TIMEOUT, msgs.toArray(new String[0])); }
config.setServerURLs(urls); assertArrayEquals(urls, config.getServerURLs());