Example #1
0
    def post(self):
        xml = request.stream.read().decode('utf-8')
        transaction_id = re.search('<OprtTrxId\>(.*)<\/OprtTrxId>', xml,
                                   re.IGNORECASE).group(1)
        status_code = re.search('<TrxStsCode\>(.*)<\/TrxStsCode>', xml,
                                re.IGNORECASE).group(1)
        message = {
            'transaction_id': transaction_id,
            'status_code': status_code
        }

        # Push this to Queue
        conf = Config.read('RABBIT')
        publisher = Publisher(conf)
        publisher.publish_message(message, 'BETUPDATE')

        app.logger.info(
            "BetOutcomeUpdateResponse Transaction code [%s], status code [%s]"
            % (transaction_id, status_code))

        return Response(
            """<?xml version="1.0" encoding="UTF-16"?><rcemsTrxSubReqAck><TrxStsCode>GBT0000</TrxStsCode></rcemsTrxSubReqAck>""",
            content_type='text/xml; charset=utf-8')
Example #2
0
    subscription_name = 'sub_one'
    message = b'Alex is pretty great'
    metadata = {
        "sender": "app",
        "vehicle_id": "V-1",
        "changed_val": "True"
    }

    publisher = Publisher(project_id, topic_name)

    print("\t\t\tPublish Test\n")

    print(f"Sending {message} to {subscription_name}\n")

    try:
        publisher.publish_message(subscription_name, message, metadata=metadata)
        print("Message successfully sent!\n")
    except Exception as e:
        print("Message was not successfully sent.")
        print(f"Exception: {e}\n")

    print("\t\t\tTopic Creation Test\n")

    print(f"Creating topic named topic-tester\n")
    topic_name = publisher.get_topic(project_id, 'topic-tester')
    print(topic_name)
    response = publisher.create_topic(topic_name)
    print(f"Response: {response}\n")

    print("\t\t\tTopic Deletion Test\n")