Kbase P53514: How to implement a good 4GL error handling for flow-control with the SonicMQ adapter
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  1/25/2005 |
|
Status: Unverified
GOAL:
How to implement a good 4GL error handling for flow-control with the SonicMQ adapter
FACT(s) (Environment):
Progress 9.1D
FIX:
If publishing of a message fails instead of recreating the whole pubsubsession
it's better to set a boolean variable as flag so that an error consumer can get activated. If there is a problem with the connection to the SonicMQ broker
than the error handler returns an error. Otherwise it's better to assume that it's just flow control which is kicking in and to slow down the publish rate. That is also a more healthy approach as it uses less CPU power for the messages publishing client machine instead of retrying at full speed.
The error handler it's self should look similar to that what is provided with example16.p that comes with the SonicMQ 4GL adapter product.
Below some code snip for such a code running as loop:
DEFINE VARIABLE hSession AS HANDLE NO-UNDO.
DEFINE VARIABLE hMsg AS HANDLE NO-UNDO.
DEF VARIABLE mcount AS INT INITIAL 1.
DEFINE VARIABLE jmsIsOk AS LOGICAL INIT FALSE.
DEFINE VARIABLE pubfailed AS LOGICAL INIT FALSE.
DEFINE VARIABLE errorConsumer AS HANDLE.
/* code within the loop */
IF pubfailed THEN
RUN waitForMessages IN hSession ("inWait", THIS-PROCEDURE, 10).
if valid-handle(hMsg) then run deletemessage in hMsg.
run createTextMessage in hSession (output hMsg).
run setText in hMsg (String(mcount) + ". test Message ").
pubfailed = TRUE.
run publish in hSession ("testTopic", hMsg, 4, ?, ?) .
mcount = mcount + 1 .
pubfailed = FALSE.
/* end of code within the loop */