Ejemplo n.º 1
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;
  }
Ejemplo n.º 2
0
  /**
   * Send request in non-blocking manner
   *
   * @param synInCtx message context
   * @return continue the mediation flow or not
   */
  private boolean handleNonBlockingCall(MessageContext synInCtx) {
    SynapseLog synLog = getLog(synInCtx);

    if (synLog.isTraceOrDebugEnabled()) {
      synLog.traceOrDebug("Start : Call mediator - Non Blocking Call");
      if (synLog.isTraceTraceEnabled()) {
        synLog.traceTrace("Message : " + synInCtx.getEnvelope());
      }
    }

    // clear the message context properties related to endpoint in last service invocation
    Set keySet = synInCtx.getPropertyKeySet();
    if (keySet != null) {
      keySet.remove(SynapseConstants.RECEIVING_SEQUENCE);
      keySet.remove(EndpointDefinition.DYNAMIC_URL_VALUE);
    }

    boolean outOnlyMessage = "true".equals(synInCtx.getProperty(SynapseConstants.OUT_ONLY));

    // Prepare the outgoing message context
    MessageContext synOutCtx = null;
    if (outOnlyMessage) {
      try {
        synOutCtx = MessageHelper.cloneMessageContext(synInCtx);
      } catch (AxisFault axisFault) {
        handleException("Error occurred while cloning msg context", axisFault, synInCtx);
      }
    } else {
      synOutCtx = synInCtx;
    }

    synOutCtx.setProperty(SynapseConstants.CONTINUATION_CALL, true);
    ContinuationStackManager.updateSeqContinuationState(synOutCtx, getMediatorPosition());

    // If no endpoints are defined, send where implicitly stated
    if (endpoint == null) {

      if (synLog.isTraceOrDebugEnabled()) {
        StringBuffer sb = new StringBuffer();
        sb.append("Calling ")
            .append(synOutCtx.isResponse() ? "response" : "request")
            .append(" message using implicit message properties..");
        sb.append("\nCalling To: ")
            .append(synOutCtx.getTo() != null ? synOutCtx.getTo().getAddress() : "null");
        sb.append("\nSOAPAction: ")
            .append(synOutCtx.getWSAAction() != null ? synOutCtx.getWSAAction() : "null");
        synLog.traceOrDebug(sb.toString());
      }

      if (synLog.isTraceTraceEnabled()) {
        synLog.traceTrace("Envelope : " + synOutCtx.getEnvelope());
      }
      synOutCtx.getEnvironment().send(null, synOutCtx);

    } else {
      endpoint.send(synOutCtx);
    }

    if (synLog.isTraceOrDebugEnabled()) {
      synLog.traceOrDebug("End : Call mediator - Non Blocking Call");
    }

    if (outOnlyMessage) {
      // For out only invocations request flow should continue
      // otherwise flow should stop from here
      return true;
    }
    return false;
  }