public void connect() throws Exception { this.next.connect().await(); }
public FutureConnection connect() throws Exception { this.connection = mqtt.futureConnection(); Future<Void> connect = connection.connect(); return connection; }
public void connect() throws Exception { this.next.connect().await(); }
/** * Get a {@link FutureConnection} to the MQTT broker. * * @return * @throws SiteWhereException */ public FutureConnection getConnection() throws SiteWhereException { FutureConnection connection = mqtt.futureConnection(); try { Future<Void> future = connection.connect(); future.await(DEFAULT_CONNECT_TIMEOUT_SECS, TimeUnit.SECONDS); return connection; } catch (Exception e) { throw new SiteWhereException("Unable to connect to MQTT broker.", e); } }
/** * Get a {@link FutureConnection} to the MQTT broker. * * @return * @throws SiteWhereException */ public FutureConnection getConnection() throws SiteWhereException { FutureConnection connection = mqtt.futureConnection(); try { Future<Void> future = connection.connect(); future.await(DEFAULT_CONNECT_TIMEOUT_SECS, TimeUnit.SECONDS); return connection; } catch (Exception e) { throw new SiteWhereException("Unable to connect to MQTT broker.", e); } }
public void setupTest(String host, String clientId, int size) { try { JMeterContext jmcx = JMeterContextService.getContext(); this.connectionArray= new FutureConnection[size]; if(size==1){ this.connectionArray[0]= createConnection(host,clientId+jmcx.getThreadNum()); this.connectionArray[0].connect().await(); this.getLogger().info("NUMBER CONNECTION: "+PublisherSampler.numberOfConnection.getAndIncrement()); } else { for(int i = 0;i< size;i++){ this.connectionArray[i]= createConnection(host,clientId+jmcx.getThreadNum()+i); this.connectionArray[i].connect().await(); this.getLogger().info("NUMBER CONNECTION: "+PublisherSampler.numberOfConnection.getAndIncrement()); } } } catch (Exception e) { getLogger().error(e.getMessage()); } } public void setupTest(String host, String clientId, String user, String password, int size) {
public void setupTest(String host, String clientId, String user, String password, int size) { try { JMeterContext jmcx = JMeterContextService.getContext(); this.connectionArray= new FutureConnection[size]; if(size==1){ this.connectionArray[0]= createConnection(host,clientId+jmcx.getThreadNum(),user,password); this.connectionArray[0].connect().await(); this.getLogger().info("NUMBER CONNECTION: "+PublisherSampler.numberOfConnection.getAndIncrement()); } else { for(int i = 0;i< size;i++){ this.connectionArray[i]= createConnection(host,clientId+jmcx.getThreadNum()+i,user,password); this.connectionArray[i].connect().await(); this.getLogger().info("NUMBER CONNECTION: "+PublisherSampler.numberOfConnection.getAndIncrement()); } } getLogger().info("Connection successful.."); } catch (Exception e) { getLogger().error(e.getMessage()); } }
@Override public void start(ILifecycleProgressMonitor monitor) throws SiteWhereException { if ((topic == null) && ((multicaster == null) && (routeBuilder == null))) { throw new SiteWhereException("No topic specified and no multicaster or route builder configured."); } // Required for filters. super.start(monitor); // Start multicaster if configured. if (multicaster != null) { startNestedComponent(multicaster, monitor, true); } // Start route builder if configured. if (routeBuilder != null) { startNestedComponent(routeBuilder, monitor, true); } // Use common MQTT configuration setup. this.queue = Dispatch.createQueue(getComponentId()); this.mqtt = MqttLifecycleComponent.configure(this, queue); LOGGER.info("Connecting to MQTT broker at '" + getHostname() + ":" + getPort() + "'..."); connection = mqtt.futureConnection(); try { Future<Void> future = connection.connect(); future.await(MqttLifecycleComponent.DEFAULT_CONNECT_TIMEOUT_SECS, TimeUnit.SECONDS); } catch (Exception e) { throw new SiteWhereException("Unable to connect to MQTT broker.", e); } LOGGER.info("Connected to MQTT broker."); }
@Override public void start(ILifecycleProgressMonitor monitor) throws SiteWhereException { if ((topic == null) && ((multicaster == null) && (routeBuilder == null))) { throw new SiteWhereException("No topic specified and no multicaster or route builder configured."); } // Required for filters. super.start(monitor); // Start multicaster if configured. if (multicaster != null) { startNestedComponent(multicaster, monitor, true); } // Start route builder if configured. if (routeBuilder != null) { startNestedComponent(routeBuilder, monitor, true); } // Use common MQTT configuration setup. this.queue = Dispatch.createQueue(getComponentId().toString()); this.mqtt = MqttLifecycleComponent.configure(this, queue); getLogger().info("Connecting to MQTT broker at '" + getHostname() + ":" + getPort() + "'..."); connection = mqtt.futureConnection(); try { Future<Void> future = connection.connect(); future.await(MqttLifecycleComponent.DEFAULT_CONNECT_TIMEOUT_SECS, TimeUnit.SECONDS); } catch (Exception e) { throw new SiteWhereException("Unable to connect to MQTT broker.", e); } getLogger().info("Connected to MQTT broker."); }