Consultor Eletrônico



Kbase P55608: How to get the properties from a SonicMQ message using the 4
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   11/21/2003
Status: Unverified

GOAL:

How to get the properties from a SonicMQ message using the 4GL Adapter ?

FACT(s) (Environment):

Progress 9.1D

FACT(s) (Environment):

SonicMQ 5.0.2

FIX:

/* Subscribes and receives a Text message. */
DEFINE VARIABLE pubsubsession AS HANDLE.
DEFINE VARIABLE consumerH AS HANDLE.

/* Creates a session object. */
RUN jms/pubsubsession.p PERSISTENT SET pubsubsession ("-H localhost -S 5162 ").
RUN setBrokerURL IN pubsubsession ("localhost:25555").
RUN beginSession IN pubsubsession.

/* Subscribe to the GolfTopic topic. Messages are handled by the
"golfHandler" internal procedure.
*/
RUN createMessageConsumer IN pubsubsession (
THIS-PROCEDURE, /* This proc will handle it */
"golfHandler", /* name of internal procedure */
OUTPUT consumerH).

RUN subscribe IN pubsubsession ("Test", /* name of topic */
?, /* Subscription is not durable */
?, /* No message selector */
no, /* Want my own messages too */
consumerH). /* Handles the incoming messages*/

/* Start receiving messages */
RUN startReceiveMessages IN pubsubsession.

/* Wait to receive the messages. Any other IO-blocked statements can be used
for receiving messages.
*/
WAIT-FOR u1 OF THIS-PROCEDURE.

PROCEDURE golfHandler:
DEFINE INPUT PARAMETER messageH AS HANDLE.
DEFINE INPUT PARAMETER msgConsumerH AS HANDLE.
DEFINE OUTPUT PARAMETER replyH AS HANDLE.

/* Display the message and the property defined in the SonicMQ message */
/* This sample code assumes only one property has been added to the message */

DISPLAY "Message text: " DYNAMIC-FUNCTION('getText':U IN messageH) FORMAT "x(70)"
"Property :" DYNAMIC-FUNCTION('getPropertyNames' IN messageH)
"Value :" DYNAMIC-FUNCTION('getCharProperty' IN messageH,INPUT DYNAMIC-FUNCTION('getPropertyNames' IN messageH)).

RUN deleteMessage IN messageH.

APPLY "U1" TO THIS-PROCEDURE.
END.