/*
  * Merges the statistics logs of the ESB artifacts that are not already
  * collected by the request flow.
  */
 private void mergeStatisticsRecords(
     final StatisticsRecord source, final StatisticsRecord destination) {
   StatisticsRecord clonedSourceStatRecord = MessageHelper.getClonedStatisticRecord(source);
   for (StatisticsLog clonedSourceStatLog : clonedSourceStatRecord.getAllStatisticsLogs()) {
     if (!clonedSourceStatLog.isCollectedByRequestFlow()) {
       destination.collect(clonedSourceStatLog);
     }
   }
 }
Beispiel #2
0
  /**
   * clone the provided message context as a new message, and mark as the messageSequence'th message
   * context of a total of messageCount messages
   *
   * @param synCtx - MessageContext which is subjected to the cloning
   * @param messageSequence - the position of this message of the cloned set
   * @param messageCount - total of cloned copies
   * @return MessageContext the cloned message context
   */
  private MessageContext getClonedMessageContext(
      MessageContext synCtx, int messageSequence, int messageCount) {

    MessageContext newCtx = null;
    try {

      newCtx = MessageHelper.cloneMessageContext(synCtx);

      StatisticsRecord statRecord =
          (StatisticsRecord) newCtx.getProperty(SynapseConstants.STATISTICS_STACK);
      if (statRecord != null) {
        for (StatisticsLog statLog : statRecord.getAllStatisticsLogs()) {
          /*
           * Marks that this statistics log is collected by the
           * request flow.
           */
          statLog.setCollectedByRequestFlow(true);
        }
      }
      // Set isServerSide property in the cloned message context
      ((Axis2MessageContext) newCtx)
          .getAxis2MessageContext()
          .setServerSide(((Axis2MessageContext) synCtx).getAxis2MessageContext().isServerSide());

      if (id != null) {
        // set the parent correlation details to the cloned MC -
        //                              for the use of aggregation like tasks
        newCtx.setProperty(EIPConstants.AGGREGATE_CORRELATION + "." + id, synCtx.getMessageID());
        // set the property MESSAGE_SEQUENCE to the MC for aggregation purposes
        newCtx.setProperty(
            EIPConstants.MESSAGE_SEQUENCE + "." + id,
            String.valueOf(messageSequence)
                + EIPConstants.MESSAGE_SEQUENCE_DELEMITER
                + messageCount);
      } else {
        newCtx.setProperty(
            EIPConstants.MESSAGE_SEQUENCE,
            String.valueOf(messageSequence)
                + EIPConstants.MESSAGE_SEQUENCE_DELEMITER
                + messageCount);
      }
    } catch (AxisFault axisFault) {
      handleException("Error cloning the message context", axisFault, synCtx);
    }

    return newCtx;
  }