Search in sources :

Example 6 with ConcurrentAccessReplicator

use of org.apache.synapse.commons.throttle.core.ConcurrentAccessReplicator in project wso2-synapse by wso2.

the class AbstractEndpoint method informFailure.

protected void informFailure(MessageContext synCtx, int errorCode, String errorMsg) {
    Boolean isConcurrencyThrottleEnabled = (Boolean) synCtx.getProperty(SynapseConstants.SYNAPSE_CONCURRENCY_THROTTLE);
    if (isConcurrencyThrottleEnabled != null && isConcurrencyThrottleEnabled) {
        ConcurrentAccessController concurrentAccessController = (ConcurrentAccessController) synCtx.getProperty(SynapseConstants.SYNAPSE_CONCURRENT_ACCESS_CONTROLLER);
        int available = concurrentAccessController.incrementAndGet();
        int concurrentLimit = concurrentAccessController.getLimit();
        if (log.isDebugEnabled()) {
            log.debug("Concurrency Throttle : Connection returned" + " :: " + available + " of available of " + concurrentLimit + " connections");
        }
        ConcurrentAccessReplicator concurrentAccessReplicator = (ConcurrentAccessReplicator) synCtx.getProperty(SynapseConstants.SYNAPSE_CONCURRENT_ACCESS_REPLICATOR);
        String throttleKey = (String) synCtx.getProperty(SynapseConstants.SYNAPSE_CONCURRENCY_THROTTLE_KEY);
        if (concurrentAccessReplicator != null) {
            concurrentAccessReplicator.replicate(throttleKey, true);
        }
    }
    if (synCtx.getProperty(SynapseConstants.LAST_ENDPOINT) == null) {
        setErrorOnMessage(synCtx, errorCode, errorMsg);
    }
    invokeNextFaultHandler(synCtx);
}
Also used : ConcurrentAccessController(org.apache.synapse.commons.throttle.core.ConcurrentAccessController) ConcurrentAccessReplicator(org.apache.synapse.commons.throttle.core.ConcurrentAccessReplicator)

Aggregations

ConcurrentAccessReplicator (org.apache.synapse.commons.throttle.core.ConcurrentAccessReplicator)6 ConcurrentAccessController (org.apache.synapse.commons.throttle.core.ConcurrentAccessController)5 EndpointReference (org.apache.axis2.addressing.EndpointReference)2 MessageContext (org.apache.axis2.context.MessageContext)2 Map (java.util.Map)1 Set (java.util.Set)1 Stack (java.util.Stack)1 ContentType (javax.mail.internet.ContentType)1 ParseException (javax.mail.internet.ParseException)1 QName (javax.xml.namespace.QName)1 SOAPFactory (org.apache.axiom.soap.SOAPFactory)1 RelatesTo (org.apache.axis2.addressing.RelatesTo)1 OperationClient (org.apache.axis2.client.OperationClient)1 Options (org.apache.axis2.client.Options)1 ClusteringAgent (org.apache.axis2.clustering.ClusteringAgent)1 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)1 ServiceContext (org.apache.axis2.context.ServiceContext)1 ServiceGroupContext (org.apache.axis2.context.ServiceGroupContext)1 AxisOperation (org.apache.axis2.description.AxisOperation)1 AxisService (org.apache.axis2.description.AxisService)1