Connection and Consumption setup

Modified on Mon, 06 May 2024 at 10:57 AM

Connecting to LSports - RabbitMQ


So you've started to implement LSports services via RMQ, great choice! Let's get your connection running with a few simple steps.

This guide is intended to provide a better understanding of how the LSports Support team works to resolve issues in a timely manner and with minimal effort on your part.

The following example refers to these credentials:
Username: MyEmail
Password: Passw0rd1234
Package: 102030
(You should use the credentials provided by LSports)

Note: All examples below are written in C#.
When you're implementing your own code, you will need to get the RMQ library here.
Please be aware that LSports currently uses version 3.12.10

  1. Start off by making sure that your distributor connection is enabled by sending an API call as follows:

https://stm-api.lsports.eu/Distribution/Start - Enable
https://stm-api.lsports.eu/Distribution/Stop - Disable

Method - POST

Body Scheme

{
    "PackageId": PackageId,
    "UserName": "UserName",
    "Password": "Password"
}

Response:
XML Schema: 

<xs:schema>
  <xs:element name="Message">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="Header">
          <xs:complexType>
            <xs:sequence>
              <xs:element type="xs:short" name="HttpStatusCode"/>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="Body">
          <xs:complexType>
            <xs:sequence>
              <xs:element type="xs:string" name="Message"/>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

JSON Schema:

{
  "type": "object",
  "properties": {
    "Header": {
      "type": "object",
      "properties": {
        "HttpStatusCode": {
          "type": "integer"
        }
      },
      "required": [
        "HttpStatusCode"
      ]
    },
    "Body": {
      "type": "object",
      "properties": {
        "Message": {
          "type": "string"
        }
      },
      "required": [
        "Message"
      ]
    }
  },
  "required": [
    "Header",
    "Body"
  ]
}

If the package was already enabled then the message should contain "Value was already set". For any other status or error message, please recheck your credentials or contact us. 

  1. Create a connection factory as follow:
ConnectionFactory connectionFactory = new ConnectionFactory
{
    HostName = "Described below",
    Port = 5672,
    UserName = "MyEmail",
    Password = "Passw0rd1234",
    AutomaticRecoveryEnabled = true,
    VirtualHost = "StmPreMatch", //For PreMatch
    VirtualHost = "StmInPlay", //For InPlay
    RequestedHeartbeat = 580,
    NetworkRecoveryInterval = TimeSpan.FromSeconds(1)
};

RMQ HostName:
InPlay: stm-inplay.lsports.eu
PreMatch: stm-prematch.lsports.eu

  1. Create a connection as follows:
IConnection connection = _connectionFactory.CreateConnection();
  1. Create a model as follows:
IModel model = connection.CreateModel();
  1. Configure the quality of service:
model.BasicQos(prefetchSize: 0, prefetchCount: 1000, global: false);
  1. Consume message:
EventingBasicConsumer consumer = new EventingBasicConsumer(model);
consumer.Received += (sender, eventArgs) =>
{
    // Deserialize message
    // Call method to handle deserialized message
};
  1. Start message consumption:
    (make sure to type in your package ID using underscores ('_') as describes) For example, if package ID was “102030”
model.BasicConsume(queue: '_102030_', noAck: true, consumer: consumer)


  • From here you should be able to pull up your RMQ connection and start receiving Heartbeat messages.

Full Snapshot Request
As updates coming through RMQ to you are deltas only before you start consuming messages coming from LSports, you should request a snapshot of the data you should be receiving.
You can do so by making an API call to the following:

Possible error types

Note: If the queue reaches 10000 unread/unacked messages it will be automatically purged and your distributor connection will be disabled.

Most failed connection attempts occur due to incorrect credentials or incorrect connection details.
Here are the most common errors and possible solutions:

"Connection failed" - Please check that the connection details i.e. Connection factory, RMQ host, VirtualHost were typed correctly.
"Access refused"- Please check that your package is enabled and the login credentials and package ID were typed correctly.

For an in-depth explanation of our data structure, you may continue reading our documentation.
Now all you need to do is, to start ordering our sports data according to your specific needs.
An email notification will be sent to your contacts upon deletion of your queue

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article