def write_responsetomessage(self, message):
        correlationid = message.correlationid
        responsecategory = to_response_category(message.category)

        response = message_repo.get_bycorrelation(correlationid, responsecategory)

        self.write(response.get_body())
        self.set_header("Content-Type", "text/turtle")
        self.finish()
    def execute(token):
        message = token.message

        # create and send result message
        correlationid = message.correlationid
        receiveraddress = message.sender.hostname
        category = to_response_category(message.category)
        body = token.result
        resultmessage = messaging_uow.store_outgoing(receiveraddress, correlationid, category, body)

        process_outgoingmessage.delay(resultmessage.id)
    def is_answered(self, message):
        correlationid = message.correlationid
        responsecategory = to_response_category(message.category)

        response = self.messagerepo.get_bycorrelation(correlationid, responsecategory)
        return response is not None and response.processed