public void disconnect() throws Exception { this.next.disconnect().await(); }
public void publish(final UTF8Buffer topic, final Buffer payload, final QoS qos, final boolean retain) throws Exception { this.next.publish(topic, payload, qos, retain).await(); }
public void kill() throws Exception { this.next.kill().await(); }
public void unsubscribe(final UTF8Buffer[] topics) throws Exception { this.next.unsubscribe(topics).await(); }
public Message receive() throws Exception { return this.next.receive().await(); }
public void connect() throws Exception { this.next.connect().await(); }
public byte[] subscribe(final Topic[] topics) throws Exception { return this.next.subscribe(topics).await(); }
public void unsubscribe(final String[] topics) throws Exception { this.next.unsubscribe(topics).await(); }
/** * @return null if the receive times out. */ public Message receive(long amount, TimeUnit unit) throws Exception { Future<Message> receive = this.next.receive(); try { Message message = receive.await(amount, unit); if( message!=null ) { message.blocking = true; } return message; } catch (TimeoutException e) { // Put it back on the queue.. receive.then(new Callback<Message>() { public void onSuccess(final Message value) { next.putBackMessage(value); } public void onFailure(Throwable value) { } }); return null; } }
public void disconnect() throws Exception { this.next.disconnect().await(); }
public Message receive() throws Exception { return this.next.receive().await(); }
public void kill() throws Exception { this.next.kill().await(); }
public void connect() throws Exception { this.next.connect().await(); }
public void unsubscribe(final String[] topics) throws Exception { this.next.unsubscribe(topics).await(); }
public void unsubscribe(final UTF8Buffer[] topics) throws Exception { this.next.unsubscribe(topics).await(); }
public void publish(final UTF8Buffer topic, final Buffer payload, final QoS qos, final boolean retain) throws Exception { this.next.publish(topic, payload, qos, retain).await(); }
@Override public void stop(ILifecycleProgressMonitor monitor) throws SiteWhereException { if (connection != null) { try { connection.disconnect().await(); connection.kill().await(); } catch (ShutdownException e) { LOGGER.info("Dispatcher has already been shut down."); } catch (Exception e) { LOGGER.error("Error shutting down MQTT device event receiver.", e); } } super.stop(monitor); }
/** * 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); } }
@Override public void stop(ILifecycleProgressMonitor monitor) throws SiteWhereException { if (connection != null) { try { connection.disconnect().await(); connection.kill().await(); } catch (ShutdownException e) { getLogger().info("Dispatcher has already been shut down."); } catch (Exception e) { getLogger().error("Error shutting down MQTT device event receiver.", e); } } super.stop(monitor); }