Progress
External Program
Interfaces
Subscribing To a Topic
In the Pub/Sub domain, applications subscribe to topics of interest.
To subscribe to a topic with Java–JMS, an application obtains as handle to a topic object, creates a subscriber object, and installs a message-handling routine in the subscriber object.
To subscribe to a topic with the 4GL–JMS API, an application implements a message handler routine for handing the incoming messages and a Message Consumer object that contains the message handler and provides context to the application when it processes messages.
Creating a Message Handler
A message-handler routine must implement a specific signature with two input parameters (the incoming message and the containing messageConsumer object) and one output parameter (for the reply message). For information about the signature of a message handler, see the "Message Handler" section in this chapter.
Creating a Message Consumer
An application creates a messageConsumer object by calling createMessageConsumer in the Session object. The input to createMessageConsumer is the handle and the name of the message handler.
In addition, the application can set more context information in the Message Consumer object. For example, an application can use the setApplicationContext procedure in the Message Consumer object to set a handle (typically a procedure handle) that the message handler (which calls getApplicationContext) can use to receive context information and to communicate message processing results to the rest of the application.
If the setReuseMessage message consumer method is called, the Message Consumer object will reuse the same Message object for all the messages it receives, provided that the message was not deleted by the application. Using setReuseMessage improves performance since message creation is relatively expensive.
Subscribing
The application calls the subscribe procedure in
pubsubsession.p
with the topic name and a handle to the messageConsumer object. For the 4GL application to subscribe to a durable subscription, it must provide the name of the subscription as well. A durable subscription is a subscription registered with the SonicMQ broker with a unique identity so the broker retains the subscription’s messages until they are received by the subscription or until they expire. The application can pass a JMS properties selector expression to the subscribe call to specify which messages the subscriber wants to receive. The application can also specify whether or not it wants to receive its own published messages.
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |