Github user johannnallathamby commented on a diff in the pull request:

    https://github.com/apache/stratos/pull/50#discussion_r22122620
  
    --- Diff: 
components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topic/instance/status/InstanceStatusEventMessageListener.java
 ---
    @@ -1,47 +1,85 @@
     /*
      * Licensed to the Apache Software Foundation (ASF) under one
    - * or more contributor license agreements.  See the NOTICE file
    + * or more contributor license agreements. See the NOTICE file
      * distributed with this work for additional information
    - * regarding copyright ownership.  The ASF licenses this file
    + * regarding copyright ownership. The ASF licenses this file
      * to you under the Apache License, Version 2.0 (the
      * "License"); you may not use this file except in compliance
    - * with the License.  You may obtain a copy of the License at
    - *
    - *     http://www.apache.org/licenses/LICENSE-2.0
    - *
    + * with the License. You may obtain a copy of the License at
    + * 
    + * http://www.apache.org/licenses/LICENSE-2.0
    + * 
      * Unless required by applicable law or agreed to in writing,
      * software distributed under the License is distributed on an
      * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    - * KIND, either express or implied.  See the License for the
    + * KIND, either express or implied. See the License for the
      * specific language governing permissions and limitations
      * under the License.
      */
     package org.apache.stratos.cloud.controller.topic.instance.status;
     
    -import org.apache.commons.logging.Log;
    -import org.apache.commons.logging.LogFactory;
    -
     import javax.jms.JMSException;
    -import javax.jms.Message;
    -import javax.jms.MessageListener;
     import javax.jms.TextMessage;
     
    +import org.apache.activemq.command.ActiveMQTextMessage;
    +import org.apache.commons.logging.Log;
    +import org.apache.commons.logging.LogFactory;
    +import org.apache.stratos.messaging.util.Constants;
    +import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
    +import org.eclipse.paho.client.mqttv3.MqttCallback;
    +import org.eclipse.paho.client.mqttv3.MqttMessage;
    +
     /**
      * this is to handle the topology subscription
      */
    -public class InstanceStatusEventMessageListener implements MessageListener{
    -    private static final Log log = 
LogFactory.getLog(InstanceStatusEventMessageListener.class);
    -
    -    @Override
    -    public void onMessage(Message message) {
    -        TextMessage receivedMessage = (TextMessage) message;
    -        InstanceStatusEventMessageQueue.getInstance().add(receivedMessage);
    -        if(log.isDebugEnabled()) {
    -            try {
    -                log.debug(String.format("Instance status message added to 
queue: %s", receivedMessage.getText()));
    -            } catch (JMSException e) {
    -                log.error(e);
    -            }
    -        }
    -    }
    +public class InstanceStatusEventMessageListener implements MqttCallback {
    +   public static final String ORG_APACHE_STRATOS_MESSAGING_EVENT =
    +                   "org.apache.stratos.messaging.event.";
    +   private static final Log log = LogFactory
    +                   .getLog(InstanceStatusEventMessageListener.class);
    +
    +   @Override
    +   public void connectionLost(Throwable arg0) {
    +           if (log.isDebugEnabled()) {
    +                   log.debug("Connection lost");
    +           }
    +
    +   }
    +
    +   @Override
    +   public void deliveryComplete(IMqttDeliveryToken arg0) {
    +           if (log.isDebugEnabled()) {
    +                   log.debug("Delivery completed");
    +           }
    +   }
    +
    +   @Override
    +   public void messageArrived(String arg0, MqttMessage message)
    +                   throws Exception {
    +           if (message instanceof MqttMessage) {
    +
    +                   TextMessage receivedMessage = new ActiveMQTextMessage();
    +
    +                   receivedMessage.setText(new 
String(message.getPayload()));
    +                   
receivedMessage.setStringProperty(Constants.EVENT_CLASS_NAME,
    +                                                     
ORG_APACHE_STRATOS_MESSAGING_EVENT
    +                                                                     
.concat(arg0.replace("/",
    +                                                                           
               ".")));
    +
    +                   try {
    +                           if (log.isDebugEnabled()) {
    +                                   log.debug(String.format(
    +                                                   "Instance notifier 
message received: %s",
    +                                                   ((TextMessage) 
message).getText()));
    +                           }
    +                           // Add received message to the queue
    +                           
InstanceStatusEventMessageQueue.getInstance().add(
    +                                           receivedMessage);
    +
    +                   } catch (JMSException e) {
    +                           log.error(e.getMessage(), e);
    --- End diff --
    
    No context aware information logged in error message.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to