def _on_message(self, ch, method, properties, body):
        print "message received!"

        data = json.loads(api.decrypt_msg(
            AppModel.objects(nid=self.nid).scalar('private_key').get(), 
            body))

        print data  
        server_id = AppModel.objects(nid=self.nid).scalar('master_sid').get()

        ## access to the shared resource has been permitted
        if (data['action'] == _ACTION_KEYS[8]):
            if server_id == data['by']:     #   for minimum integrity
                #   this data format is to save contents by 'add_comments' function
                #   send all data that is locally stored then it will be filtered to store to
                #   the shared resource inside 'add_comments' function
                data = {
                    'permission':True,      #   this action would be only triggered with master server's permission
                    'nid':self.nid,
                    'sid':data['by'],
                    'content':map(lambda x:{
                            'by':x.by,
                            'created_at':x.timestamp,
                            'comment':x.comment,
                            'session_id':x.session_id
                        }, CommentReplicaModel.objects.all())
                }

                app_api.add_comments(**data)  
    def execute_command(self, encrypted_action):
        print "server calling rpc"
        
        data = json.loads(
            api.decrypt_msg(self.model.private_key, encrypted_action))

        action = data['action']
        print action

        ## response from master server has arrived, stop trying to reach other servers
        if self.timer.is_alive():
            self.timer.stop()

        ## server sent info
        if (action == api._ACTION_KEYS[0]):
            self._store_server_info(data['data'], self.model.nid)

        ## add comments 
        elif(action == api._ACTION_KEYS[5]):
            data['nid'] = self.model.nid
            """data['content'].update(
                    {
                    'nid':self.model.nid,
                    'sid':data['sid']
                    })"""
        
            return api.encrypt_msg(AppModel.objects(
                nid=self.model.nid).get().server_public_key,
                    app_api.add_comments(**data))