Code Samples

Notes

  • Replace credentials and customerPackageId placeholders with your assigned values.

  • Queue name on both vhosts: _{CustomerPackageId}_.

Python

import pika
import ssl
import json
import threading
HOST = "hyper-livescore.lsports.eu"
QNAME = f"_{customer_package_id}_"
def make_params(vhost: str, username: str, password: str) -> pika.ConnectionParameters:
    context = ssl.create_default_context()
    # Relaxed SSL per policy; force TLS 1.2+
    context.check_hostname = False
    context.verify_mode = ssl.CERT_NONE
    context.options |= ssl.OP_NO_TLSv1 | ssl.OP_NO_TLSv1_1
    return pika.ConnectionParameters(
        host=HOST,
        port=5671,
        virtual_host=vhost,                        # "Fixtures" or "Incidents"
        credentials=pika.PlainCredentials(username, password),
        ssl_options=pika.SSLOptions(context, server_hostname=None),
        heartbeat=60,
        connection_attempts=5,
        retry_delay=10,
    )
# /Fixtures
fx_conn = pika.BlockingConnection(make_params("Fixtures", "fixtures-username", "fixtures-password"))
fx_ch = fx_conn.channel()
fx_ch.queue_declare(queue=QNAME, passive=True)  # verify only
# /Incidents
ic_conn = pika.BlockingConnection(make_params("Incidents", "incidents-username", "incidents-password"))
ic_ch = ic_conn.channel()
ic_ch.queue_declare(queue=QNAME, passive=True)  # verify only
def on_fixture(ch, method, props, body):
    m = json.loads(body.decode("utf-8"))
    # upsert by m["body"]["fixtureId"]  (delta-only)
def on_incident(ch, method, props, body):
    m = json.loads(body.decode("utf-8"))
    # correlate by m["body"]["fixtureId"] against your fixtures store
fx_ch.basic_consume(queue=QNAME, on_message_callback=on_fixture, auto_ack=True)
ic_ch.basic_consume(queue=QNAME, on_message_callback=on_incident, auto_ack=True)
# Run both consumers
threading.Thread(target=fx_ch.start_consuming, daemon=True).start()
print("Consuming from Fixtures and Incidents ...")
ic_ch.start_consuming()

C#

Java

Last updated

Was this helpful?