stratos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From im...@apache.org
Subject [1/2] git commit: Fixing class cast error and refining code in TopologyEventMessageListener
Date Fri, 24 Oct 2014 07:18:07 GMT
Repository: stratos
Updated Branches:
  refs/heads/master 2758d936a -> 9758c8364


Fixing class cast error and refining code in TopologyEventMessageListener


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/df7db412
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/df7db412
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/df7db412

Branch: refs/heads/master
Commit: df7db412d1cb0de2431e04ea96b2b9b79a8c8263
Parents: b23a9c7
Author: Imesh Gunaratne <imesh@apache.org>
Authored: Fri Oct 24 12:47:46 2014 +0530
Committer: Imesh Gunaratne <imesh@apache.org>
Committed: Fri Oct 24 12:47:46 2014 +0530

----------------------------------------------------------------------
 .../topology/TopologyEventMessageListener.java  | 71 +++++++++-----------
 1 file changed, 32 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/df7db412/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyEventMessageListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyEventMessageListener.java
b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyEventMessageListener.java
index 54774ea..54d43ce 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyEventMessageListener.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyEventMessageListener.java
@@ -32,52 +32,45 @@ import org.eclipse.paho.client.mqttv3.MqttMessage;
 
 /**
  * Implements functionality for receiving text based event messages from the
- * topology
- * message broker topic and add them to the event queue.
+ * topology message broker topic and add them to the event queue.
  */
 class TopologyEventMessageListener implements MqttCallback {
-	private static final Log log = LogFactory.getLog(TopologyEventMessageListener.class);
+    private static final Log log = LogFactory.getLog(TopologyEventMessageListener.class);
 
-	private final TopologyEventMessageQueue messageQueue;
+    private final TopologyEventMessageQueue messageQueue;
 
-	public TopologyEventMessageListener(TopologyEventMessageQueue messageQueue) {
-		this.messageQueue = messageQueue;
-	}
+    public TopologyEventMessageListener(TopologyEventMessageQueue messageQueue) {
+        this.messageQueue = messageQueue;
+    }
 
-	@Override
-	public void connectionLost(Throwable arg0) {
-		// TODO Auto-generated method stub
+    @Override
+    public void connectionLost(Throwable throwable) {
+        log.warn("Connection is lost", throwable);
+    }
 
-	}
+    @Override
+    public void deliveryComplete(IMqttDeliveryToken deliveryToken) {
+        if (log.isDebugEnabled()) {
+            log.debug(String.format("Message delivery is complete: %s",
+                    ((deliveryToken != null) ? deliveryToken.toString() : "")));
+        }
+    }
 
-	@Override
-	public void deliveryComplete(IMqttDeliveryToken arg0) {
-		// TODO Auto-generated method stub
+    @Override
+    public void messageArrived(String topicName, MqttMessage message) throws Exception {
+        TextMessage textMessage = new ActiveMQTextMessage();
+        textMessage.setText(new String(message.getPayload()));
+        textMessage.setStringProperty(Constants.EVENT_CLASS_NAME, Util.getEventNameForTopic(topicName));
 
-	}
-
-	@Override
-	public void messageArrived(String topicName, MqttMessage message) throws Exception {
-		if (message instanceof MqttMessage) {
-
-			TextMessage receivedMessage = new ActiveMQTextMessage();
-
-			receivedMessage.setText(new String(message.getPayload()));
-			receivedMessage.setStringProperty(Constants.EVENT_CLASS_NAME,
-			                                  Util.getEventNameForTopic(topicName));
-
-			try {
-				if (log.isDebugEnabled()) {
-					log.debug(String.format("topology message received: %s",
-					                        ((TextMessage) message).getText()));
-				}
-				// Add received message to the queue
-				messageQueue.add(receivedMessage);
-
-			} catch (JMSException e) {
-				log.error(e.getMessage(), e);
-			}
-		}
-	}
+        try {
+            if (log.isDebugEnabled()) {
+                log.debug(String.format("Topology message received: %s", textMessage.getText()));
+            }
+            // Add received message to the queue
+            messageQueue.add(textMessage);
 
+        } catch (JMSException e) {
+            log.error(e.getMessage(), e);
+        }
+    }
 }


Mime
View raw message