8. Enabling Queuing

This section describes how to add queuing to a minimum UM source and receiver with the following.

UMQ Prerequisite: You should understand basic Ultra Messaging® concepts such as Sources and Receivers along with the basic methods for configuring them.

The following table lists all source files used in this section. You can also find links to them in the appropriate task. The files can also be found in the /doc/UME directory.

Object Filename
Source Application q-example-src.c
Receiver Application q-example-rcv.c
UMQ Configuration File q-example-config.xml

8.1. Starting Configuration

We begin with the minimal source and receiver used by the UM QuickStart Guide. To more easily demonstrate the UMQ features we are interested in, we have modified the QuickStart source and receiver in the following ways.

The last change allows us to better demonstrate basic operation and evolve our receiver slowly without having to anticipate all the options that UMQ provides up front.

Note: Be sure to build q-example-src.c and q-example-rcv.c. Instructions for building them are at the beginning of the source files.

8.2. Adding a Queue to a Source

To enable queuing, a source needs to be configured to use a queue by setting the umq_queue_name for the source. The following q-example-src.c code sets the source's queue to the queue_name established in the UMQ configuration file (q-example-config.xml ).

err = lbm_src_topic_attr_str_setopt(&attr, "umq_queue_name", queue_name);

Examining q-example-config.xml reveals that queue_name is set to Queue Training and listens on port 14567 for registrations.

Let's instantiate the queue with the following command.

$ umestored q-example-config.xml

8.3. Sending to the Queue

Further examination of q-example-config.xml shows that the Queue Training is configured for Serial Queue Dissemination (SQD). In this model, sources send messages to topics as usual, but receivers interested in the topic need not even be started because topic messages go to the Queue first.

Therefore we can take the next step and run the source with the following command.

$ q-example-src

The sample output below shows that the source sends 20 messages on the UME Queue Example topic.

tmont@agentmbp:/Volumes/source$ ./q-example-src 
INFO: Host has multiple multicast-capable interfaces. Default multicast interface: [en1][192.168.0.41] 
INFO: Source "UME Queue Example" Late Join not set, but UME store or UMQ queue specified. Setting Late Join. 
Sent Message 01 
Sent Message 02 
Sent Message 03 
Sent Message 04 
Sent Message 05 
Sent Message 06 
Sent Message 07 
Sent Message 08 
Sent Message 09 
Sent Message 10 
Sent Message 11 
Sent Message 12 
Sent Message 13 
Sent Message 14 
Sent Message 15 
Sent Message 16 
Sent Message 17 
Sent Message 18 
Sent Message 19 
Sent Message 20

8.4. Receiving from the Queue

At this point, only the Queue is running. The receiving application can start up at anytime and receive any messages from the Queue on the topic it subscribes to.

tmont@agentmbp:/Volumes/source$ ./q-example-rcv 
INFO: Host has multiple multicast-capable interfaces. Default multicast interface: [en1][192.168.0.41] 
Received 20 bytes on topic UME Queue Example: 'UME Queue Message 01' 
Received 20 bytes on topic UME Queue Example: 'UME Queue Message 02' 
Received 20 bytes on topic UME Queue Example: 'UME Queue Message 03' 
Received 20 bytes on topic UME Queue Example: 'UME Queue Message 04' 
Received 20 bytes on topic UME Queue Example: 'UME Queue Message 05' 
Received 20 bytes on topic UME Queue Example: 'UME Queue Message 06' 
Received 20 bytes on topic UME Queue Example: 'UME Queue Message 07' 
Received 20 bytes on topic UME Queue Example: 'UME Queue Message 08' 
Received 20 bytes on topic UME Queue Example: 'UME Queue Message 09' 
Received 20 bytes on topic UME Queue Example: 'UME Queue Message 10' 
Received 20 bytes on topic UME Queue Example: 'UME Queue Message 11' 
Received 20 bytes on topic UME Queue Example: 'UME Queue Message 12' 
Received 20 bytes on topic UME Queue Example: 'UME Queue Message 13' 
Received 20 bytes on topic UME Queue Example: 'UME Queue Message 14' 
Received 20 bytes on topic UME Queue Example: 'UME Queue Message 15' 
Received 20 bytes on topic UME Queue Example: 'UME Queue Message 16' 
Received 20 bytes on topic UME Queue Example: 'UME Queue Message 17' 
Received 20 bytes on topic UME Queue Example: 'UME Queue Message 18' 
Received 20 bytes on topic UME Queue Example: 'UME Queue Message 19' 
Received 20 bytes on topic UME Queue Example: 'UME Queue Message 20'

Copyright 2007 - 2014 Informatica Corporation.