def send_content()

in gnm_deliverables/signals.py [0:0]


    def send_content(self, routing_key:str, payload:bytes, connect_attempt=0):
        max_attempts = getattr(settings,"RABBITMQ_MAX_SEND_ATTEMPTS",10)
        try:
            channel = MessageRelay.setup_connection()
            channel.basic_publish(
                exchange='pluto-deliverables',
                routing_key=routing_key,
                body=payload
            )
        except (pika.exceptions.ChannelWrongStateError, pika.exceptions.AMQPConnectionError, pika.exceptions.AMQPChannelError) as e:
            if "CI" in os.environ:
                logger.warning("Ignoring connection error as we are in CI mode")
                return
            if connect_attempt>max_attempts:
                logger.error("Could not re-establish broker connection after {0} attempts, giving up")
                raise
            else:
                sleep(2*connect_attempt)
                logger.warning("Message queue connection was lost: {0}. Attempting to reconnect, attempt {1}".format(str(e), connect_attempt))
                self.send_content(routing_key, payload, connect_attempt+1)