Search in sources :

Example 51 with SynapseLog

use of org.apache.synapse.SynapseLog in project wso2-synapse by wso2.

the class SamplingThrottleMediator method mediate.

public boolean mediate(MessageContext messageContext) {
    if (messageContext.getEnvironment().isDebuggerEnabled()) {
        if (super.divertMediationRoute(messageContext)) {
            return true;
        }
    }
    SynapseLog synLog = getLog(messageContext);
    synLog.traceOrDebug("Start : Sampler mediator");
    if (synLog.isTraceTraceEnabled()) {
        synLog.traceTrace("Message : " + messageContext.getEnvelope());
    }
    if (!messageContext.isResponse()) {
        if (synLog.isTraceOrDebugEnabled()) {
            synLog.traceOrDebug("Adding the message with message id : " + messageContext.getMessageID() + " into the message queue for sampling");
        }
        messageQueue.add(messageContext);
    } else {
        synLog.auditWarn("Encountered a response message which will not be sampled");
    }
    OperationContext opCtx = ((Axis2MessageContext) messageContext).getAxis2MessageContext().getOperationContext();
    if (opCtx != null) {
        opCtx.setProperty(Constants.RESPONSE_WRITTEN, "SKIP");
    }
    synLog.traceOrDebug("End : Sampler mediator");
    return false;
}
Also used : OperationContext(org.apache.axis2.context.OperationContext) SynapseLog(org.apache.synapse.SynapseLog)

Example 52 with SynapseLog

use of org.apache.synapse.SynapseLog in project wso2-synapse by wso2.

the class AbstractListMediator method mediate.

public boolean mediate(MessageContext synCtx, int mediatorPosition) {
    boolean returnVal = true;
    int parentsEffectiveTraceState = synCtx.getTracingState();
    // if I have been explicitly asked to enable or disable tracing, set it to the message
    // to pass it on; else, do nothing -> i.e. let the parents state flow
    setEffectiveTraceState(synCtx);
    int myEffectiveTraceState = synCtx.getTracingState();
    try {
        SynapseLog synLog = getLog(synCtx);
        if (synLog.isTraceOrDebugEnabled()) {
            synLog.traceOrDebug("Sequence <" + getType() + "> :: mediate()");
            synLog.traceOrDebug("Mediation started from mediator position : " + mediatorPosition);
        }
        for (int i = mediatorPosition; i < mediators.size(); i++) {
            // ensure correct trace state after each invocation of a mediator
            Mediator mediator = mediators.get(i);
            if (sequenceContentAware && (mediator.isContentAware() || isStreamXpathEnabled) && (!Boolean.TRUE.equals(synCtx.getProperty(PassThroughConstants.MESSAGE_BUILDER_INVOKED)))) {
                buildMessage(synCtx, synLog);
            }
            if (RuntimeStatisticCollector.isStatisticsEnabled()) {
                Integer statisticReportingIndex = mediator.reportOpenStatistics(synCtx, i == mediatorPosition);
                synCtx.setTracingState(myEffectiveTraceState);
                if (!mediator.mediate(synCtx)) {
                    mediator.reportCloseStatistics(synCtx, statisticReportingIndex);
                    returnVal = false;
                    break;
                }
                mediator.reportCloseStatistics(synCtx, statisticReportingIndex);
            } else {
                synCtx.setTracingState(myEffectiveTraceState);
                if (!mediator.mediate(synCtx)) {
                    returnVal = false;
                    break;
                }
            }
        }
    } catch (SynapseException synEx) {
        // Now create matcher object.
        Matcher msgBuildFailureExMatcher = msgBuildFailureExpattern.matcher(ExceptionUtils.getStackTrace(synEx));
        if (msgBuildFailureExMatcher.find()) {
            consumeInputOnOmException(synCtx);
        }
        throw synEx;
    } catch (Exception ex) {
        String errorMsg = ex.getMessage();
        // Now create matcher object.
        Matcher msgBuildFailureExMatcher = msgBuildFailureExpattern.matcher(ExceptionUtils.getStackTrace(ex));
        if (errorMsg == null) {
            errorMsg = "Runtime error occurred while mediating the message";
        }
        if (msgBuildFailureExMatcher.find()) {
            consumeInputOnOmException(synCtx);
        }
        handleException(errorMsg, ex, synCtx);
    } finally {
        synCtx.setTracingState(parentsEffectiveTraceState);
    }
    return returnVal;
}
Also used : SynapseLog(org.apache.synapse.SynapseLog) SynapseException(org.apache.synapse.SynapseException) Matcher(java.util.regex.Matcher) Mediator(org.apache.synapse.Mediator) SynapseException(org.apache.synapse.SynapseException)

Example 53 with SynapseLog

use of org.apache.synapse.SynapseLog in project wso2-synapse by wso2.

the class SynapseMediator method mediate.

/**
 * Perform the mediation specified by the rule set
 *
 * @param synCtx the message context
 * @return as per standard mediate() semantics
 */
public boolean mediate(MessageContext synCtx) {
    if (synCtx.getEnvironment().isDebuggerEnabled()) {
        if (super.divertMediationRoute(synCtx)) {
            return true;
        }
    }
    SynapseLog synLog = getLog(synCtx);
    if (synLog.isTraceOrDebugEnabled()) {
        synLog.traceOrDebug("Start : Mediation using '" + SynapseConstants.MAIN_SEQUENCE_KEY + "' sequence Message is a : " + (synCtx.isResponse() ? "response" : "request"));
        if (synLog.isTraceTraceEnabled()) {
            synLog.traceTrace("Message : " + synCtx.getEnvelope());
        }
    }
    boolean result = super.mediate(synCtx);
    if (synLog.isTraceOrDebugEnabled()) {
        if (synLog.isTraceTraceEnabled()) {
            synLog.traceTrace("Message : " + synCtx.getEnvelope());
        }
        synLog.traceOrDebug("End : Mediation using '" + SynapseConstants.MAIN_SEQUENCE_KEY + "' sequence");
    }
    return result;
}
Also used : SynapseLog(org.apache.synapse.SynapseLog)

Aggregations

SynapseLog (org.apache.synapse.SynapseLog)53 Mediator (org.apache.synapse.Mediator)16 FlowContinuableMediator (org.apache.synapse.mediators.FlowContinuableMediator)13 SynapseException (org.apache.synapse.SynapseException)10 Axis2MessageContext (org.apache.synapse.core.axis2.Axis2MessageContext)9 MessageContext (org.apache.synapse.MessageContext)8 AbstractMediator (org.apache.synapse.mediators.AbstractMediator)8 OMNode (org.apache.axiom.om.OMNode)7 AbstractListMediator (org.apache.synapse.mediators.AbstractListMediator)6 SequenceMediator (org.apache.synapse.mediators.base.SequenceMediator)6 JaxenException (org.jaxen.JaxenException)5 PreparedStatement (java.sql.PreparedStatement)4 Set (java.util.Set)4 AxisFault (org.apache.axis2.AxisFault)4 OperationContext (org.apache.axis2.context.OperationContext)4 SOAPEnvelope (org.apache.axiom.soap.SOAPEnvelope)3 ReliantContinuationState (org.apache.synapse.continuation.ReliantContinuationState)3 Endpoint (org.apache.synapse.endpoints.Endpoint)3 IOException (java.io.IOException)2 Method (java.lang.reflect.Method)2