Ejemplo n.º 1
0
    def post(self):
        sender = self.get_parameter('sender')
        content = self.get_parameter('content')

        if sender is None:
            raise badrequest('parameter "sender" not provided')

        if content is None:
            raise badrequest('parameter "content" not provided')

        # persist so it can be processed in the background
        correlationid, category, position, body = extract_all(content)
        message = messaging_uow.store_incoming(sender, correlationid, category, position, body)

        # if message is complete, create processing task
        if message.complete:
            process_incomingmessage.delay(message.id)

        self.accepted()
Ejemplo n.º 2
0
    def get(self, receiveraddress):
        query = self.get_parameter('query')

        if query is None:
            raise badrequest('parameter "query" not provided')

        # persist so it can be processed in the background
        correlationid = gen_correlationid()
        message = messaging_uow.store_outgoing(receiveraddress, correlationid, MessageCategory.SPARQL_QUERY, query)

        try:
            outgoing = process_outgoingmessage.delay(message.id)

            def check(): return outgoing.ready() and messaging_uow.is_answered(message)
            self.asyncwait(check, 1, 30, self.write_responsetomessage, message)

        except TimeoutError:
            raise timeout('the incoming "SparqlQuery" request has timed out')
        except Exception:
            raise servererror('the incoming "SparqlQuery" request failed')