Implementing Exception Handling for Synchronous Message Processing

When a an outbound synchronous request fails you can throw a framework exception leading to a message box error and subsequent component roll back of the transaction.

Note: This type of exception handling applies to outbound synchronous requests only, including outbound multi-threaded synchronous requests.

For example, if 10 synchronous requests are performed in parallel (threaded sync request), you have the option to select the User Exception check box on the routing definition for the service operation. When the User Exception check box is selected, if any of the synchronous requests error, the component is not rolled back. You can check each synchronous request to determine if there is an error and actually read the associated error message. You can then throw an exception or go on to process the next synchronous request in the array.

See Understanding Routing Definitions.

The following example shows sample PeopleCode to read the exception:

Local Rowset &FLIGHTPLAN, &FLIGHTPLAN_RETURN;
Local array of Message &messages;
Local array of Message &return_mesages;

&messages = CreateArrayRept(&MSG, 2);
&return_mesages = CreateArrayRept(&MSG, 2);

QE_FLIGHTDATA.QE_ACNUMBER.Value = QE_FLIGHTDATA.QE_ACNUMBER + 1;

&FLIGHT_PROFILE = GetLevel0();

&rs1 = &FLIGHT_PROFILE.GetRow(1).GetRowset(Scroll.QE_NAVIGATION);
&rs2 = &FLIGHT_PROFILE.GetRow(1).GetRowset(Scroll.QE_RADAR_PRESET);
&rs3 = &FLIGHT_PROFILE.GetRow(1).GetRowset(Scroll.QE_ARMAMENT);
&messages [1] = CreateMessage(Operation.SYNC_PARTS);

For &i = 1 To &messages [1].PartCount
   
   If &i = 1 Then
      &rs1.CopyTO(&messages [1].GetPartRowset(&i));      
   End-If;
   
   If &i = 2 Then
      &rs2.CopyTO(&messages [1].GetPartRowset(&i));    
   End-If;
   
   If &i = 3 Then
      &rs3.CopyTO(&messages [1].GetPartRowset(&i));
   End-If;
   
End-For;

&messages [2] = CreateMessage(Operation.SYNC_PARTS);

For &i = 1 To &messages [2].PartCount
   
   If &i = 1 Then
      &rs1.CopyTO(&messages [2].GetPartRowset(&i));
   End-If;
   
   If &i = 2 Then
      &rs3.CopyTO(&messages [2].GetPartRowset(&i));
   End-If;
   
   If &i = 3 Then
      &rs2.CopyTO(&messages [2].GetPartRowset(&i));
   End-If;
   
End-For;

&return_mesages = %IntBroker.SyncRequest(&messages);

If &return_mesages [1].ResponseStatus = %IB_Status_Success Then
   
   For &i = 1 To &return_mesages [1].PartCount
      
//perform local processing on response data

   End-For;
   
Else
   
   &nMsgNumber = &return_mesages [1].IBException.MessageNumber;
   &nMsgSetNumber = &return_mesages [1].IBException.MessageSetNumber;
  &exceptString = &return_mesages [1].IBException.ToString();
// Evaluate exception and throw error if necessary
   
End-If;

If &return_mesages [2].ResponseStatus = %IB_Status_Success Then
   
   For &i = 1 To &return_mesages [2].PartCount
      
  //perform local processing on response data   End-For;
   
  Else
   
   &nMsgNumber = &return_mesages [2].IBException.MessageNumber;
   &nMsgSetNumber &return_mesages [2].IBException.MessageSetNumber;
  &exceptString = &return_mesages [2].IBException.ToString();

// Evaluate exception and throw error if necessary
   
End-If;