Kbase P127702: How to implement the requestReply procedure within a ABL-JMS client?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  12/17/2007 |
|
Status: Unverified
GOAL:
How to implement the requestReply procedure within a ABL-JMS client?
GOAL:
How to use the requestReply procedure when sending a message?
GOAL:
ABL sample of ABL-JMS client using requestReply procedure?
FACT(s) (Environment):
OpenEdge 10.x
All Supported Operating Systems
FIX:
The sample code below illustrates messaging to a queue using the requestReply procedure for receiving reply messages from a message consumer. It populates the JMSReplyTo header field automatically:
/* Publishes a message and receives a reply. */
DEFINE VARIABLE jmssession AS HANDLE.
DEFINE VARIABLE consumerH AS HANDLE.
DEFINE VARIABLE messageH AS HANDLE.
/* Creates a session object. */
RUN jms/jmssession.p PERSISTENT SET jmssession("-SMQConnect").
RUN setBrokerURL IN jmssession ("localhost:2506").
RUN SETUSER IN jmssession ("Administrator").
RUN setPassword IN jmssession ("Administrator").
RUN beginSession IN jmssession.
/* Start receiving messages */
RUN startReceiveMessages IN jmssession.
/* Create a text message */
RUN createTextMessage IN jmssession (OUTPUT messageH).
RUN setText IN messageH ("Golf shoes on sale today.").
/* Creates a consumer for the reply */
RUN createMessageConsumer IN jmssession (THIS-PROCEDURE, /* This proc will handle it */
"messageHandler", /* name of internal procedure */
OUTPUT consumerH).
/* Send the message onto Sample.Q1. Handle the reply in the messageHandler internal procedure.*/
RUN requestReply IN jmssession ("Sample.Q1", /* destination */
messageH, /* message */
?, /* No reply selector. */
consumerH, /* messageConsumer */
?, /* priority */
?, /* timeToLive */
?). /* deliveryMode */
RUN deleteMessage IN messageH.
/* Wait forever to receive messages since "u1" is never applied. */
WAIT-FOR u1 OF THIS-PROCEDURE.
PROCEDURE messageHandler:
DEFINE INPUT PARAMETER replyH AS HANDLE.
DEFINE INPUT PARAMETER msgConsumerH AS HANDLE.
DEFINE OUTPUT PARAMETER responseH AS HANDLE.
/* Display the reply - we are not sending a response. */
DISPLAY "reply text: " DYNAMIC-FUNCTION('getText':U IN replyH) FORMAT "X(70)".
DISPLAY "Reply Persistency:" DYNAMIC-FUNCTION('getReplyPersistency':U IN msgConsumerH) FORMAT "x(70)".
DISPLAY "R.eply Time To Live:" DYNAMIC-FUNCTION('getReplyTimeToLive':U IN msgConsumerH) FORMAT "x(70)".
RUN deleteMessage IN replyH.
END..