Kbase 21704: Request Reply: using SmartSender and SmartReceiver objects.
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  15/10/2008 |
|
SUMMARY:
This article will illustrate what is needed to implement a Request Reply mechanism using Progress' SmartSender and SmartReceiver objects.
EXPLANATION:
A SmartSender can declare that it wants more than just an acknowledgement from the SonicMQ broker that it received a message. The SmartSender may want to, depending on business rules, request that consumers of the message, SmartReceivers, reply back directly to the SmartSender to explicitly state that it consumed a message. The Request Reply mechanism, in effect, is a reversal of roles whereby the consumer is a producer and the producer becomes a consumer.
SOLUTION:
Modify the instance properties of the Smart Sender and check off Reply Required. Unchecked is the default. Checking off Reply Required notifies the consumer that you wish a reply to your message. You need to code for the consumer's reply which occurs in the receiveReplyHandler procedure located in the Smart Sender. Reply Selector can be used if you wish to filter incoming replies using sql-92, e.g.
cust-num >= 5
The Smart Receiver does not have any instance properties to set, however, you do need to code for the sendReplyHandler procedure.
Below is example code of the receiveReplyHandler and sendReplyHandler procedures:
/**************** receiveReplyHandler *********************/
DEFINE INPUT PARAMETER phMessage AS HANDLE NO-UNDO.
DEF VAR cReplyToMessage AS CHARACTER NO-UNDO.
cReplyToMessage = DYNAMIC-FUNCTION('getTextSegment' IN phMessage).
MESSAGE "SmartSender displaying the replytomessage " +
cReplyToMessage VIEW-AS ALERT-BOX.
MESSAGE "This is the Reply to MESSAGE being received! " + STRING(phMEssage) VIEW-AS ALERT-BOX.
END PROCEDURE.
/**************** sendReplyHandler ***************************/
DEFINE INPUT PARAMETER phMessage AS HANDLE NO-UNDO.
MESSAGE "This message being sent by SendReplyHandler in SmartReceiver" VIEW-AS ALERT-BOX.
RUN settext IN phMessage('This is the SendReplyHandler Message').
END PROCEDURE.
References to Written Documentation:
AppBuilder Developer's Guide