Code Samples

This section provides working code examples for connecting to the TRADE RabbitMQ feed in various programming languages.

Available Samples

Language
File
Description

.NET Core consumer

Complete consumer with message handling

JavaScript/TypeScript

Event-based consumer using amqplib

Python 3.x

Consumer using pika library

PHP 7.4+

Consumer using php-amqplib

Golang

Consumer using streadway/amqp

Browser/Node

Basic JavaScript implementation

Prerequisites

Before running any code sample, ensure you have:

  1. Valid credentials - Package ID, username, and password from your CSM

  2. Enabled distribution - Call the Distribution/Start API endpoint

  3. Network access - Firewall rules allowing connection to stm-rmq.lsports.eu:5671

Common Configuration

All samples require the following connection parameters:

Message Flow

Best Practices

  1. Enable automatic recovery - Handle connection drops gracefully

  2. Process messages asynchronously - Don't block the message loop

  3. Implement proper logging - Track message flow and errors

  4. Monitor heartbeats - Detect feed issues early

  5. Use prefetch - Control message buffer size

Need Help?

If you need a code sample for a language not listed here, contact our support team.

Last updated

Was this helpful?