def valid_message_receive()

in rabbitmq/AtomResponderProcessor.py [0:0]


    def valid_message_receive(self, exchange_name, routing_key, delivery_tag, body):
        """
        handles the incoming message
        :param exchange_name:
        :param routing_key:
        :param delivery_tag:
        :param body:
        :return:
        """
        msg = AtomResponderMessage(**body)

        if msg.type == const.MESSAGE_TYPE_MEDIA or msg.type == const.MESSAGE_TYPE_RESYNC_MEDIA:
            logger.info("Received notification of a master {0} at item {1}".format(msg.title, msg.itemId))
            (asset, created) = self.get_or_create_record(msg.atomId, msg.projectId, msg.commissionId)
            asset.online_item_id = msg.itemId
            asset.job_id = msg.jobId    ##once we save this value, we can process the notifications when the job completes
            asset.size = msg.size
            asset.filename = msg.title
            if created:
                asset.status = AssetChoices.DELIVERABLE_ASSET_STATUS_INGESTING  #FIXME: it might not be this state?
            asset.save()
            if created:
                try:
                    self.set_vs_metadata(asset)
                except Exception as e:
                    logger.exception("Could not update Vidispne metadata on {}: ".format(asset.online_item_id), exc_info=e)
        elif msg.type == const.MESSAGE_TYPE_PAC:
            logger.info("PAC messages not implemented yet")
        elif msg.type == const.MESSAGE_TYPE_PROJECT_ASSIGNED:
            (asset, created) = self.get_or_create_record(msg.atomId, msg.projectId, msg.commissionId)
            if created:
                logger.warning("Strange, got a project re-assignment message for something that does not exist yet")
            self.reassign_project(asset, msg.projectId, msg.commissionId)
        else:
            raise ValueError("Did not recognise message type {}".format(msg.type))