@Test public void testNotifyTopicPublished() throws Exception { MqttPublishMessage msg = MqttMessageBuilders.publish().qos(MqttQoS.AT_MOST_ONCE).payload(Unpooled.copiedBuffer("Hello".getBytes())).build(); MoquetteMessage moquetteMessage = new MoquetteMessage(msg.fixedHeader(), msg.variableHeader(), msg.content()); interceptor.notifyTopicPublished(moquetteMessage, "cli1234", "cli1234"); interval(); assertEquals(60, n.get()); }
@Override public void notifyTopicPublished(final MoquetteMessage msg, final String clientID, final String username) { int messageId = msg.getMessageId(); String topic = msg.getTopic(); for (final InterceptHandler handler : this.handlers.get(InterceptPublishMessage.class)) { if(LOG.isDebugEnabled()){ LOG.debug("Notifying MQTT PUBLISH message to interceptor. CId={}, messageId={}, topic={}, interceptorId={}", clientID, messageId, topic, handler.getID()); } executor.execute(new Runnable() { @Override public void run() { handler.onPublish(new InterceptPublishMessage(msg, clientID, username)); } }); } }
BrokerInterceptor implements Interceptor { @Override public void notifyTopicPublished(final MoquetteMessage msg, final String clientID, final String username) { int messageId = msg.getMessageId(); String topic = msg.getTopic(); for (final InterceptHandler handler : this.handlers.get(InterceptPublishMessage.class)) { if(LOG.isDebugEnabled()){ LOG.debug("Notifying MQTT PUBLISH message to interceptor. CId={}, messageId={}, topic={}, interceptorId={}", clientID, messageId, topic, handler.getID()); } executor.execute(new Runnable() { @Override public void run() { handler.onPublish(new InterceptPublishMessage(msg, clientID, username)); } }); } } }
BrokerInterceptor implements Interceptor { @Override public void notifyTopicPublished(final MoquetteMessage msg, final String clientID, final String username) { int messageId = msg.getMessageId(); String topic = msg.getTopic(); for (final InterceptHandler handler : this.handlers.get(InterceptPublishMessage.class)) { if(LOG.isDebugEnabled()){ LOG.debug("Notifying MQTT PUBLISH message to interceptor. CId={}, messageId={}, topic={}, interceptorId={}", clientID, messageId, topic, handler.getID()); } executor.execute(new Runnable() { @Override public void run() { handler.onPublish(new InterceptPublishMessage(msg, clientID, username)); } }); } } private  BrokerInterceptor(int poolSize, List<InterceptHandler> handlers);   BrokerInterceptor(List<InterceptHandler> handlers);   BrokerInterceptor(IConfig props, List<InterceptHandler> handlers); }
BrokerInterceptor implements Interceptor { @Override public void notifyTopicPublished(final MoquetteMessage msg, final String clientID, final String username) { int messageId = msg.getMessageId(); String topic = msg.getTopic(); for (final InterceptHandler handler : this.handlers.get(InterceptPublishMessage.class)) { if(LOG.isDebugEnabled()){ LOG.debug("Notifying MQTT PUBLISH message to interceptor. CId={}, messageId={}, topic={}, interceptorId={}", clientID, messageId, topic, handler.getID()); } executor.execute(new Runnable() { @Override public void run() { handler.onPublish(new InterceptPublishMessage(msg, clientID, username)); } }); } } private  BrokerInterceptor(int poolSize, List<InterceptHandler> handlers);   BrokerInterceptor(List<InterceptHandler> handlers);   BrokerInterceptor(IConfig props, List<InterceptHandler> handlers); @Override void notifyClientConnected(final MqttConnectMessage msg); @Override void notifyClientDisconnected(final String clientID, final String username); @Override void notifyClientConnectionLost(final String clientID, final String username); @Override void notifyTopicPublished(final MoquetteMessage msg, final String clientID, final String username); @Override void notifyTopicSubscribed(final Subscription sub, final String username); @Override void notifyTopicUnsubscribed(final String topic, final String clientID, final String username); @Override void notifyMessageAcknowledged(final InterceptAcknowledgedMessage msg); @Override void addInterceptHandler(InterceptHandler interceptHandler); @Override void removeInterceptHandler(InterceptHandler interceptHandler); }
BrokerInterceptor implements Interceptor { @Override public void notifyTopicPublished(final MoquetteMessage msg, final String clientID, final String username) { int messageId = msg.getMessageId(); String topic = msg.getTopic(); for (final InterceptHandler handler : this.handlers.get(InterceptPublishMessage.class)) { if(LOG.isDebugEnabled()){ LOG.debug("Notifying MQTT PUBLISH message to interceptor. CId={}, messageId={}, topic={}, interceptorId={}", clientID, messageId, topic, handler.getID()); } executor.execute(new Runnable() { @Override public void run() { handler.onPublish(new InterceptPublishMessage(msg, clientID, username)); } }); } } private  BrokerInterceptor(int poolSize, List<InterceptHandler> handlers);   BrokerInterceptor(List<InterceptHandler> handlers);   BrokerInterceptor(IConfig props, List<InterceptHandler> handlers); @Override void notifyClientConnected(final MqttConnectMessage msg); @Override void notifyClientDisconnected(final String clientID, final String username); @Override void notifyClientConnectionLost(final String clientID, final String username); @Override void notifyTopicPublished(final MoquetteMessage msg, final String clientID, final String username); @Override void notifyTopicSubscribed(final Subscription sub, final String username); @Override void notifyTopicUnsubscribed(final String topic, final String clientID, final String username); @Override void notifyMessageAcknowledged(final InterceptAcknowledgedMessage msg); @Override void addInterceptHandler(InterceptHandler interceptHandler); @Override void removeInterceptHandler(InterceptHandler interceptHandler);  }