Kbase 21642: ADM2 - Message-Handling Objects: SmartProducer/SmartConsumer
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  10/16/2008 |
|
Status: Unverified
GOAL:
ADM2. How to use messaging with Progress Smartobjects and SonicMQ, namely the SmartProducer and SmartConsumer available in Progress V9.1C.
FACT(s) (Environment):
Progress 9.1C
SonicMQ
FIX:
Progress Software provides two message-handling objects, the SmartProducer and SmartConsumer.
The SmartProducer sends messages and the SmartConsumer receives them. These SmartObjects along with your ADM application, will allow you to implement a messaging system utilizing SonicMQ and the 4GL-JMS API. Progress also supplies the SmartSender and SmartReceiver objects that are used as templates. These objects have handler routines that handle the outbound and inbound message and can be used in place of the SmartB2BObject if you do not have a need to transform 4GL to XML. This solution will not use the SmartB2BObject or SmartRouter.
Sending a message requires that the SmartProducer and a OUTMESSAGE-SOURCE (OMS)SmartSender work together.
This is the process by which this is accomplished.
1) When a message is to be sent, the SmartSender calls sendMessage in the SmartProducer, e.g.
RUN sendMessage.
2) The sendMessage() procedure in the SmartProducer creates an empty message. It then calls sendHandler() in the SmartSender, passing the handle of the message it created, e.g.
DEFINE INPUT PARAMETER pcDestination AS CHARACTER NO-UNDO.
DEFINE INPUT PARAMETER plReplyRequired AS LOGICAL NO-UNDO.
DEFINE INPUT PARAMETER pcReplySelector AS CHARACTER NO-UNDO.
DEFINE OUTPUT PARAMETER pcMessageID AS CHARACTER NO-UNDO.
/* Code placed here will execute PRIOR to standard behavior. */
RUN SUPER(pcDestination, plReplyRequired, pcReplySelector, OUTPUT pcMessageID).
3) The sendHandler() routine in the SmartSender sets the message header properties, adds a body to the message, and returns, e.g.
DEFINE INPUT PARAMETER phMessage AS HANDLE NO-UNDO.
DEFINE VARIABLE ptpsession AS HANDLE NO-UNDO.
MESSAGE "This is phMessage " + STRING(phMessage) VIEW-AS ALERT-BOX.
RUN settext IN phMessage("Message being sent by Smartsender ").
/* This adds body to message */
4) The sendMessage procedure in the SmartProducer now has a complete message to send and calls the relevant routines in the 4GL-JMS API to start the message on its way.
Receiving a message requires that the SmartConsumer and an object serving as the INMESSAGE-TARGET (IMT) SmartReceiver work together. If you use a SmartRouter to distribute incoming messages, the SmartRouter acts as an IMT proxy, accepting calls from the SmartConsumer and passing them on transparently to the real IMT. The routines below ignore the role of the SmartRouter:
1) When a message is received, the messageHandler() routine in the SmartConsumer calls the receiveHandler() routine in the SmartReceiver passing the handle of the received message.
DEFINE INPUT PARAMETER phMessage AS HANDLE NO-UNDO.
DEFINE INPUT PARAMETER phMessageConsumer AS HANDLE NO-UNDO.
DEFINE OUTPUT PARAMETER phReply AS HANDLE NO-UNDO.
/* Code placed here will execute PRIOR to standard behavior. */
RUN SUPER(phMessage, phMessageConsumer, OUTPUT phReply).
/* Code placed here will execute AFTER standard behavior. */
2) The receiveHandler() routine in the SmartReceiver extracts header properties and the message body, performs any desired processing and returns, e.g.
DEFINE INPUT PARAMETER phMessage AS HANDLE NO-UNDO.
DEFINE VARIABLE cMessage AS CHARACTER NO-UNDO.
ASSIGN cMessage = DYNAMIC-FUNCTION('getTextSegment' IN phmessage).
MESSAGE "This is the message being received by the smartReceiver " + cMessage VIEW-AS ALERT-BOX.
This now completes the message handling routine.