Release 10.1A: OpenEdge Development:
Messaging and ESB

> ## Installing an error handler for synchronous errors

> The procedure example17.p publishes a `TextMessage` to a nonexistent topic and handles the error conditions, as shown:

> example17.p
>     /* Publishes A Text message to an illegal topic name and handles the
>        error conditions. */
>     DEFINE VARIABLE pubsubsession AS HANDLE.
>     DEFINE VARIABLE messageH AS HANDLE.
>     DEFINE VARIABLE Successful-publish AS LOGICAL INIT false.
>     /* Creates a session object. */
>     RUN jms/pubsubsession.p PERSISTENT SET pubsubsession
>                                       ("-H localhost -S 5162 ").
>     RUN setNoErrorDisplay IN pubsubsession (true).
>     RUN setBrokerURL IN pubsubsession ("localhost:2506").
>     RUN beginSession IN pubsubsession.
>     /* Create a text message */
>     RUN createTextMessage IN pubsubsession (OUTPUT messageH).
>     RUN setText IN messageH ("Golf shoes on sale today.").
>     /* Publish the message on the illegal '*' topic */
>     DO ON ERROR UNDO, LEAVE:
>       RUN publish IN pubsubsession ("*", messageH, ?, ?, ?).
>       Successful-publish = true.
>     END.
>     If NOT Successful-publish THEN
>         MESSAGE "Failed to publish to topic '*': " RETURN-VALUE VIEW-AS ALERT-BOX.
>     RUN deleteMessage IN messageH.
>     RUN deleteSession IN pubsubsession.

Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095