Connection and Consumption setup

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 implementing your code, you 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:

<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>

If the package was enabled 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 follows:

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

Staying Up-to-Date with TRADE360 Data

When you subscribe to a fixture (event) on TRADE360, the first message you receive will be a complete picture, including all data for the fixture and its markets. This is followed by updates (deltas) that only reflect changes to the data.

Reconnecting and Getting Back on Track

If you ever disconnect from the TRADE360 feed, it's important to request a snapshot of the data before you start consuming the feed again. This ensures you have the latest information. You can request a snapshot using an API call. LSports offers two types of snapshots:

By comparing the timestamps of the snapshot data with the timestamps of the updates you receive in the feed, you can identify any missing information and keep your data synchronized.

Possible error types

Note: If the queue reaches 10000 unread/unpacked 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

Last updated