Skip to main content

Establishing a Connection

For receiving events, the Reporting API requires a connection to RabbitMQ, a well-known message broker suite.

warning

Connections to our RabbitMQ node are only possible from whitelisted IPs. To whitelist your IPs, please provide them to Spotware's service assurance team.

To connect to RabbitMQ, all you have to do is perform these actions.

  1. Run Stunnel on your machine and route your connection through it.
  2. Connect to the correct host and create a channel.
info

All C# examples below use the RabbitMQ.Client Nuget package, which you can install using any suitable Nuget package management service.

info

All Java examples below use the RabbitMQ Java client that you can install using any suitable dependency management system or build tool such as Maven or Gradle.

Routing Your Connection Via Stunnel

Stunnel is an application that you can use to provide TSL/SSL encryption functionality to a connection.

To connect to the RabbitMQ node, Stunnel should be successfully deployed and accessible from your client. Stunnel should also be configured properly; this configuration is provided by Spotware's service assurance team.

Connecting to the Host

After routing your connection via Stunnel and whitelisting your IPs, you will have to connect to the correct host via your application or service. This can be done as follows.

info

The values of hostName, password, portNumber, and userName are provided by Spotware's service assurance team upon request.

warning

Connections are meant to handle many operations and, therefore, should stay open for long periods of time. It would be inefficient to establish a new connection for every new action you need to perform.

Connecting to RabbitMQ

C#

var factory = new ConnectionFactory { 
HostName = hostName,
Password = password,
Port = portNumber,
UserName = userName,
};

IConnection conn = factory.CreateConnection();

var channel = conn.CreateModel();

Java

ConnectionFactory factory = new ConnectionFactory();
factory.setUsername(userName);
factory.setPassword(password);
factory.setVirtualHost(virtualHost);
factory.setHost(hostName);
factory.setPort(portNumber);

Connection conn = factory.newConnection();

var channel = conn.createChannel();

info

Note that it is possible to establish multiple connections to our RabbitMQ node. If you choose to do so, all events sent via RabbitMQ will be split according to the round-robin principle.

At this point, you should be ready to receive events; this functionality is covered in a separate tutorial.