@Override public void messageArrived(String topic, MqttMessage mqttMessage) throws Exception { LOGGER.info("message arrived on topic: " + topic); final byte[] data = mqttMessage.getPayload(); for (final String topicKey : topicListeners.keySet()) { if (isTopicMatch(topicKey, topic)) { final AWSIotMqttTopic topicModel = topicListeners.get(topicKey); if (topicModel != null) { if (topicModel.getCallback() != null) { topicModel.getCallback().onMessageArrived(topic, data); } } } } }
@Test public void topicMatchingTest() throws Exception { for (TopicMatchTestCase tc : testCases) { assertEquals(tc.matches, client.isTopicMatch(tc.topicFilter, tc.topic)); } }
@Override public void messageArrived(String topic, MqttMessage mqttMessage) throws Exception { LOGGER.info("message arrived on topic: " + topic); final byte[] data = mqttMessage.getPayload(); for (final String topicKey : topicListeners.keySet()) { if (isTopicMatch(topicKey, topic)) { final AWSIotMqttTopic topicModel = topicListeners.get(topicKey); if (topicModel != null) { if (topicModel.getCallback() != null) { topicModel.getCallback().onMessageArrived(topic, data); } } } } }