Receiving TCAP service events

After binding to a TCAP user SAP with ctaOpenServices, the application receives TCAP service events by periodically calling ctaWaitEvent, specifying the Natural Access queue handle. The TCAP service can generate data events and congestion events.

ret = ctaWaitEvent( ctaQueue, &event, CTA_WAIT_FOREVER );
if ( ret != SUCCESS )
   /* handle the error */
else
{
   switch ( event.id )
   {
      case TCAPEVN_DATA:
         /* an TCAP date event has occured, call TCAPRetrieveMessage() 
            to retrieve the message and proccess it */
         tcret = TCAPRetrieveMessage( ctaHd, &msg, &infoBlk );
         if( ret == TCAP_SUCCESS )
             /* process received TCAP event */
         else if( ret == TCAP_NOMSG 
             /* this is normal - just ignore and wait for next event */
         else
             /* TCAPRetrieveMessage failed - handle the error */
       
         break;

      case TCAPEVN_CONGEST:
         /* TCAP layer or API is congested or congestion abated;
            take appropriate action */
         cong_lvl = (U8) event.value;
         if( cong_lvl == 0 )
             /* congestion abated - restore traffic to normal levels */
         else
             /* congestion now at level "cong_lvl" - take appropriate
                action to reduce traffic. */

         break;

      .
      .
      .
   }
}

When a TCAPEVN_DATA event is received, the application calls TCAPRetrieveMessage to retrieve the TCAP message for processing. The message could be a TCAP transaction message, or other type of indication, such as a status or notify event. It is possible for TCAPRetrieveMessage to return a value of TCAP_NOMSG, indicating that the event was processed internally by the TCAP service, and there is nothing for the application to process. This usually occurs before a congestion event is generated, but can also happen at other times.

If a TCAPEVN_CONGEST event is received, the outbound congestion level of the TCAP user SAP has changed. The new congestion level is contained in the value field of the event structure returned by ctaWaitEvent. Upon receipt of this event, the application should take action to reduce (in the case of congestion onset) or restore (in the case of congestion abatement) the traffic load it is generating.

It is also recommended that the application call TCAPStateReq and mark the subsystem in service as soon as it is ready to handle data traffic, in case the subsystem was previously left out of service by an application unbinding from the same TCAP service access point.