External event publishing

FTM supports publication of external events in the following contexts:
  • Triggered by an internal event.
  • Controlled by modeled metadata.
  • Emitter flows to produce the external content.
  • Core support for publication protocols.

Publication rules are designed and modeled as part of the overall application model in Rational®. Publication is always triggered by an internal event that conforms to the Common Base Event specification. Publishing rules are modeled as optional metadata on any of the internal event definitions. For more information about how to model publishing rules, see FTM Model Tools.

For each publishing rule attached to an event definition, the name of the external event emitter must be defined. A filter to restrict publication to a subset of the internal event, based on its context data, can also be specified. The name of the emitter must match a deployed message flow label. The filter format is identical to the format that is used for event filters on transitions.

Events are evaluated for publication in the context from which they are raised, not in the context of any transitions they might cause. The external event emitter is provided with access to:
  • The internal event.
  • The object selector data for the transition objects when the event was raised.
A function-based API is provided for the emitter to use to access this data:
FUNCTION InitInternalEventRef(INOUT rEnvRoot REFERENCE)
RETURNS BOOLEAN;

PROCEDURE IterateInternalEventRef(INOUT rIntEvent REFERENCE)
RETURNS BOOLEAN;

FUNCTION InitContextDataRef(IN rIntEvent REFERENCE,
                            IN cCtxName CHAR,
                            OUT rCtxVal REFERENCE)
RETURNS BOOLEAN;

FUNCTION IterateContextDataRef(INOUT rCtxVal REFERENCE)
RETURNS BOOLEAN;

FUNCTION GetNonAggrContextVal(IN rIntEvent REFERENCE,
                              IN cCtxName CHAR)
RETURNS CHAR;

FUNCTION InitTransObjectsRef(INOUT rEnvRoot REFERENCE)
RETURNS BOOLEAN;

PROCEDURE GetObjDataById(IN rTransObjects REFERENCE,
                         IN id INTEGER,
                         IN rObj REFERENCE);
The sample application provides two examples of a publishing emitter that demonstrates use of the API.
-- initialize references to internal event and obj selector data (both
-- can  be used to populate the external event)
IF InitInternalEventRef(rIntEvent) THEN
   -- if needed, you can access non aggregated context in the event
   -- DECLARE cBatchId CHAR GetNonAggrContextVal(rIntEvent, 'BATCH');

   IF InitTransObjectsRef(rObjData) THEN
      -- Need to iterate through all txns in the internal event,
      -- so init a reference to the first one
      -- Note  you can access other aggregated context in the
      --       same way - just keep the calls to
      --       InitContextDataRef/IterateContextDataRef in step
      DECLARE rBatchContext REFERENCE TO rIntEvent;
      DECLARE bLastMove BOOLEAN
              InitContextDataRef(rIntEvent, 'BATCH', rBatchContext);
      -- then iterate over all of them
      DECLARE rObj ROW;
      DECLARE rBulk REFERENCE TO rObjData;

      WHILE bLastMove DO
         SET nBatId = CAST(rBatchContext AS INTEGER);
         CALL GetObjDataById(rObjData, nBatId, rObj);

         CREATE LASTCHILD OF
                OutputRoot.XMLNSC.BulkPaymentComplete
                AS rBulk NAME 'PaymentInf';

         SET rBulk.PT_ID     = rObj.TRANSMISSION_ID;
         SET rBulk.BAT_ID    = nBatId;
         SET rBulk.BAT_TYPE  = rObj.SUBTYPE;
         SET rBulk.CID       = rObj.CID;
         SET rBulk.TXN_COUNT = rObj.TXN_COUNT;
         SET rBulk.AMOUNT    = rObj.VALUE_AMOUNT;

         SET bLastMove = IterateContextDataRef(rBatchContext);
      END WHILE;
   END IF;
END IF;