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;
}
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;
}
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;
}
Aggregations