Kbase P127703: How to reply to a message in a ABL-JMS message consumer application?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  12/18/2007 |
|
Status: Unverified
GOAL:
How to reply to a message in a ABL-JMS message consumer application?
GOAL:
How to reply using the JMSReplyTo header field after receiving a message?
GOAL:
ABL sample of ABL-JMS client replying to a message using the JMSReplyTo header field?
FACT(s) (Environment):
OpenEdge 10.x
All Supported Operating Systems
OpenEdge Category: Language (4GL/ABL)
FIX:
The sample code below illustrates replying to a message, that was consumed from a queue, that has the JMSReplyTo header field set:
DEFINE VARIABLE jmssession AS HANDLE.
DEFINE VARIABLE consumerH 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.
/* Subscribe to the Sample.Q1 queue.
Messages are handled by the "messageHandler" internal procedure. */
RUN createMessageConsumer IN jmssession (THIS-PROCEDURE, /* This proc will handle it */
"messageHandler", /* name of internal procedure */
OUTPUT consumerH).
/* Do not create a new message for each received message */
RUN setReuseMessage IN consumerH.
RUN receiveFromQueue IN jmssession ("Sample.Q1", /* name of queue */
?, /* No message selector */
consumerH) NO-ERROR. /* Handles incoming messages*/
/* Start receiving messages */
RUN startReceiveMessages IN jmssession.
/* Wait forever to receive messages since "u1" is never applied. */
WAIT-FOR u1 OF THIS-PROCEDURE.
PROCEDURE messageHandler:
DEFINE INPUT PARAMETER messageH AS HANDLE.
DEFINE INPUT PARAMETER msgConsumerH AS HANDLE.
DEFINE OUTPUT PARAMETER replyH AS HANDLE.
/* Creates a reply message. The reply is published automatically when
control returns to the ABL?JMS implementation.
*/
DISPLAY DYNAMIC-FUNCTION('getText':U IN messageH) format "x(70)".
DISPLAY chr(13) DYNAMIC-FUNCTION('getJMSReplyTo':U IN messageH) FORMAT "x(70)".
DISPLAY "Reply Persistency:" DYNAMIC-FUNCTION('getReplyPersistency':U IN msgConsumerH) FORMAT "x(70)".
DISPLAY "Reply Time To Live:" DYNAMIC-FUNCTION('getReplyTimeToLive':U IN msgConsumerH) FORMAT "x(70)".
IF DYNAMIC-FUNCTION('hasReplyTo':U IN messageH) THEN
DO:
RUN createTextMessage IN jmssession (OUTPUT replyH).
RUN setText IN replyH ("Will bid. Send data in sportsXML format.").
END.
RUN deleteMessage IN messageH.
END.