public void send(MessageContext synCtx) {
boolean traceOn = isTraceOn(synCtx);
boolean traceOrDebugOn = isTraceOrDebugOn(traceOn);
if (traceOrDebugOn) {
traceOrDebug(traceOn, "Start : Address Endpoint");
if (traceOn && trace.isTraceEnabled()) {
trace.trace("Message : " + synCtx.getEnvelope());
}
}
boolean isClusteringEnable = false;
// get Axis2 MessageContext and ConfigurationContext
org.apache.axis2.context.MessageContext axisMC =
((Axis2MessageContext) synCtx).getAxis2MessageContext();
ConfigurationContext cc = axisMC.getConfigurationContext();
//The check for clustering environment
ClusterManager clusterManager = cc.getAxisConfiguration().getClusterManager();
if (clusterManager != null &&
clusterManager.getContextManager() != null) {
isClusteringEnable = true;
}
String endPointName = this.getName();
if (endPointName == null) {
if (traceOrDebugOn && isClusteringEnable) {
log.warn(SALoadbalanceEndpoint.WARN_MESSAGE);
}
endPointName = SynapseConstants.ANONYMOUS_ENDPOINT;
}
if (isClusteringEnable) {
// if this is a cluster environment , then set configuration context to endpoint context
if (endpointContext.getConfigurationContext() == null) {
endpointContext.setConfigurationContext(cc);
endpointContext.setContextID(endPointName); // The context ID
}
}
EndpointDefinition endpoint = getEndpoint();
// Setting Required property to collect the End Point statistics
boolean statisticsEnable
= (SynapseConstants.STATISTICS_ON == endpoint.getStatisticsState());
if (statisticsEnable) {
EndPointStatisticsStack endPointStatisticsStack = null;
Object statisticsStackObj =
synCtx.getProperty(org.apache.synapse.SynapseConstants.ENDPOINT_STATS);
if (statisticsStackObj == null) {
endPointStatisticsStack = new EndPointStatisticsStack();
synCtx.setProperty(org.apache.synapse.SynapseConstants.ENDPOINT_STATS,
endPointStatisticsStack);
} else if (statisticsStackObj instanceof EndPointStatisticsStack) {
endPointStatisticsStack = (EndPointStatisticsStack) statisticsStackObj;
}
if (endPointStatisticsStack != null) {
boolean isFault = synCtx.getEnvelope().getBody().hasFault();
endPointStatisticsStack.put(endPointName, System.currentTimeMillis(),
!synCtx.isResponse(), statisticsEnable, isFault);
}
}
if (endpoint.getAddress() != null) {
if (traceOrDebugOn) {
traceOrDebug(traceOn, "Sending message to endpoint : " +
endPointName + " resolves to address = " + endpoint.getAddress());
traceOrDebug(traceOn, "SOAPAction: " + (synCtx.getSoapAction() != null ?
synCtx.getSoapAction() : "null"));
traceOrDebug(traceOn, "WSA-Action: " + (synCtx.getWSAAction() != null ?
synCtx.getWSAAction() : "null"));
if (traceOn && trace.isTraceEnabled()) {
trace.trace("Envelope : \n" + synCtx.getEnvelope());
}
}
}
// register this as the immediate fault handler for this message.
synCtx.pushFaultHandler(this);
// add this as the last endpoint to process this message. it is used by statistics code.
synCtx.setProperty(SynapseConstants.PROCESSED_ENDPOINT, this);
synCtx.getEnvironment().send(endpoint, synCtx);
}
Sends the message through this endpoint. This method just handles statistics related
functions and gives the message to the Synapse environment to send. It does not add any
endpoint specific details to the message context. These details are added only to the cloned
message context by the Axis2FlexibleMepClient. So that we can reuse the original message
context for resending through different endpoints. |