/* Receives the customer table in a Stream message. */
DEFINE VARIABLE hPubSubSession AS HANDLE NO-UNDO. DEFINE VARIABLE msgConsumer1 AS HANDLE NO-UNDO. DEFINE TEMP-TABLE ttCustomer NO-UNDO LIKE customer. RUN jms/pubsubsession.p PERSISTENT SET hPubSubSession ("-H localhost -S 5162 "). RUN setBrokerURL IN hPubSubSession ("localhost:2506"). RUN beginSession IN hPubSubSession. RUN createMessageConsumer IN hPubSubSession (THIS-PROCEDURE, "messageHandler", OUTPUT msgConsumer1). RUN subscribe IN hPubSubSession ("topic1", ?, /* not a durable subscription */ ?, /* no message selector */ FALSE, /* no local events */ msgConsumer1). RUN startReceiveMessages IN hPubSubSession. WAIT-FOR u1 OF THIS-PROCEDURE. FOR EACH ttCustomer: DISPLAY ttCustomer WITH 2 COLUMN. END. RUN deleteSession IN hPubSubSession. PROCEDURE messageHandler: DEFINE INPUT PARAMETER hMessage AS HANDLE NO-UNDO. DEFINE INPUT PARAMETER hMessageConsumer AS HANDLE NO-UNDO. DEFINE OUTPUT PARAMETER hReply AS HANDLE NO-UNDO. DEFINE VARIABLE rawCust AS RAW NO-UNDO. DO WHILE NOT DYNAMIC-FUNCTION('endOfStream' IN hMessage): DYNAMIC-FUNCTION('moveToNext':U IN hMessage). rawCust = DYNAMIC-FUNCTION('readBytesToRaw':U IN hMessage). RAW-TRANSFER rawCust TO ttCustomer. RELEASE ttCustomer. END. RUN deleteMessage IN hMessage. APPLY "U1" TO THIS-PROCEDURE. END PROCEDURE. |
/* Publishes the customer table in a Stream message. */
DEFINE VARIABLE hMesg AS HANDLE NO-UNDO. DEFINE VARIABLE hPubSubSession AS HANDLE NO-UNDO. DEFINE VARIABLE rawCust AS RAW NO-UNDO. RUN jms/pubsubsession.p PERSISTENT SET hPubSubSession ("-H localhost -S 5162 "). RUN setBrokerURL IN hPubSubSession ("localhost:2506"). RUN beginSession IN hPubSubSession. RUN createStreamMessage IN hPubSubSession (OUTPUT hMesg). FOR EACH customer NO-LOCK: RAW-TRANSFER customer TO rawCust. RUN writeBytesFromRaw IN hMesg(rawCust). END. RUN publish IN hPubSubSession ("topic1", hMesg, ?, ?, ?). RUN deleteMessage IN hMesg. RUN deleteSession IN hPubSubSession. |