LSEG Data Library for .NET

Delivery.Queue.Queue object

A class providing queueing capabilities for Research, News headlines and stories.

Syntax

Delivery.Queue.Definition()

Delivery.Queue.Definition(string endpointUrl)

Define the queue properties to manage and retrieve messages from queues defined within the cloud.

Queueing capabilities currently support Research, News headlines and stories.

Delivery.Queue.Params()

Defines a request to specify query parameters when retrieving a message queue from the cloud.

Refer to the "message-services" endpoints within the RDP Playground for the available parameters.

This method returns a ParamsDefinition.

Methods of Queue definition

Endpoint(string endpoint)

Endpoint(Uri endpoint)

A reference to a message queue resource within the cloud.

The endpoint URL refers to message queue services such as Research, News Headlines, News Stories, etc.

CreateQueueManager()

Based on the specified message queue resource, as defined by the Endpoint specification,
define a queue manager that supports the ability to manage queues within the cloud.

CreateAWSSubscriber(IQueueNode queue)

For the specified queue, create a queue subscriber to pull data from that queue.

Methods and properties of Params definition

QueryParameters(string key, string value)

Apply the specified key/value pair as a Query parameter to the Queue request.

For example, a key/value pair such as: 'userID'/'user123' will be formed as "userID=user123" within the URL request.

Query

The defined query parameters.

The possible values for the Queue.CloudType:

Value Description
AWS Amazon Web Services

Returned value

QueueDefinition object.

In some cases described above, a ParamsDefinition object.

Usage

The following example demonstrates how to use a Queue Definition:

const string newsStoriesEndpoint = "https://api.refinitiv.com/message-services/v1/news-stories/subscriptions";

ISession session = Sessions.GetSession();

if (session.Open() == Session.State.Opened)
{
    var definition = Queue.Definition(newsStoriesEndpoint);

    // Create a QueueManager to actively manage our queues
    var manager = definition.CreateQueueManager()
                            .OnError((err, qm) => Console.WriteLine(err));

    // First, check to see if we have any news headline queues active in the cloud...
    List<IQueueNode> queues = manager.GetAllQueues();

    // Determine if we retrieved anything...create on if not.  
    IQueueNode queue = (queues.Count > 0 ? queues[0] : manager.CreateQueue());

    // Ensure our queue is created
    if (queue != null)
    {
        // Start pulling off news headline messages from the queue - we need to define a subscriber
        var subscriber = definition.CreateAWSSubscriber(queue);

        try
        {
            // Open the subscriber to begin polling for messages. Use Async() as this method is a long running task.
            var task = subscriber.StartPollingAsync((story, s) => DisplayStory(story));

            // Let the program run for a few seconds before proceeding via key press 
            Console.ReadKey();

            // Close the subscription - stops polling for messages
            subscriber.StopPolling();
            task.GetAwaiter().GetResult();
            Console.Write("\nStopped polling for messages from the queue. <Enter> to exit...");
        }
        catch (Exception e)
        {
            Console.WriteLine(e);
        }

        Console.ReadLine();
    }
}