Package org.apache.synapse.endpoints
Class FailoverEndpoint
- java.lang.Object
-
- org.apache.synapse.FaultHandler
-
- org.apache.synapse.endpoints.AbstractEndpoint
-
- org.apache.synapse.endpoints.FailoverEndpoint
-
- All Implemented Interfaces:
Endpoint
,ManagedLifecycle
,Nameable
,PropertyInclude
,SynapseArtifact
public class FailoverEndpoint extends AbstractEndpoint
FailoverEndpoint can have multiple child endpoints. It will always try to send messages to current endpoint. If the current endpoint is failing, it gets another active endpoint from the list and make it the current endpoint. Then the message is sent to the current endpoint and if it fails, above procedure repeats until there are no active endpoints. If all endpoints are failing and parent endpoint is available, this will delegate the problem to the parent endpoint. If parent endpoint is not available it will pop the next FaultHandler and delegate the problem to that.
-
-
Field Summary
-
Fields inherited from class org.apache.synapse.endpoints.AbstractEndpoint
anonymous, artifactContainerName, CHILDREN_JSON_ATT, errorHandler, fileName, initialized, isClusteringEnabled, log, NAME_JSON_ATT, trace, TYPE_JSON_ATT
-
-
Constructor Summary
Constructors Constructor Description FailoverEndpoint()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
createJsonRepresentation()
void
init(SynapseEnvironment synapseEnvironment)
This method should implement the initialization of the implemented parts of the configuration.boolean
isBuildMessageAtt()
boolean
isDynamic()
void
onChildEndpointFail(Endpoint endpoint, MessageContext synMessageContext)
Endpoints that contain other endpoints should implement this method.boolean
readyToSend()
Returns true to indicate that the endpoint is ready to service requestsvoid
send(MessageContext synCtx)
Sends the message context according to an endpoint specific behavior.void
setBuildMessageAtt(boolean buildMessage)
Set buildMessage Attribute from failover configvoid
setBuildMessageAttAvailable(boolean available)
Set whether failover config has the buildMessage configvoid
setDynamic(boolean dynamic)
-
Methods inherited from class org.apache.synapse.endpoints.AbstractEndpoint
addProperties, addProperty, destroy, evaluateProperties, executeEpTypeSpecificFunctions, getArtifactContainerName, getChildren, getCommentsList, getContext, getDefinition, getDescription, getEndpointChildrenAsJson, getErrorHandler, getFileName, getIsEdited, getJsonRepresentation, getMetricsMBean, getName, getParentEndpoint, getProperties, getProperty, getReportingName, handleException, handleException, handleException, informFailure, isAnonymous, isInitialized, isLeafEndpoint, isRetry, isSuspendFault, isTimeout, isTraceOn, isTraceOrDebugOn, logOnChildEndpointFail, logSetter, onFault, onSuccess, prepareForEndpointStatistics, removeProperty, setAdvancedProperties, setAnonymous, setArtifactContainerName, setChildren, setCommentsList, setComponentStatisticsId, setContentAware, setDefinition, setDescription, setEnableMBeanStats, setErrorHandler, setErrorOnMessage, setFileName, setForceBuildMC, setIsEdited, setName, setParentEndpoint, toString, traceOrDebug
-
Methods inherited from class org.apache.synapse.FaultHandler
executeExtendedSynapseHandlerOnFault, getStackTrace, handleFault, handleFault
-
-
-
-
Method Detail
-
init
public void init(SynapseEnvironment synapseEnvironment)
Description copied from interface:ManagedLifecycle
This method should implement the initialization of the implemented parts of the configuration.- Specified by:
init
in interfaceManagedLifecycle
- Overrides:
init
in classAbstractEndpoint
- Parameters:
synapseEnvironment
- SynapseEnvironment to be used for initialization
-
send
public void send(MessageContext synCtx)
Description copied from interface:Endpoint
Sends the message context according to an endpoint specific behavior.- Specified by:
send
in interfaceEndpoint
- Overrides:
send
in classAbstractEndpoint
- Parameters:
synCtx
- MessageContext to be sent.
-
onChildEndpointFail
public void onChildEndpointFail(Endpoint endpoint, MessageContext synMessageContext)
Description copied from interface:Endpoint
Endpoints that contain other endpoints should implement this method. It will be called if a child endpoint causes an exception. Action to be taken on such failure is up to the implementation. But it is good practice to first try addressing the issue. If it can't be addressed propagate the exception to parent endpoint by calling parent endpoint's onChildEndpointFail(...) method.- Specified by:
onChildEndpointFail
in interfaceEndpoint
- Overrides:
onChildEndpointFail
in classAbstractEndpoint
- Parameters:
endpoint
- The child endpoint which caused the exception.synMessageContext
- MessageContext that was used in the failed attempt.
-
readyToSend
public boolean readyToSend()
Description copied from interface:Endpoint
Returns true to indicate that the endpoint is ready to service requests- Specified by:
readyToSend
in interfaceEndpoint
- Overrides:
readyToSend
in classAbstractEndpoint
- Returns:
- true if endpoint is ready to service requests
-
createJsonRepresentation
protected void createJsonRepresentation()
- Specified by:
createJsonRepresentation
in classAbstractEndpoint
-
isDynamic
public boolean isDynamic()
-
isBuildMessageAtt
public boolean isBuildMessageAtt()
-
setDynamic
public void setDynamic(boolean dynamic)
-
setBuildMessageAtt
public void setBuildMessageAtt(boolean buildMessage)
Set buildMessage Attribute from failover config- Parameters:
buildMessage
- true or false
-
setBuildMessageAttAvailable
public void setBuildMessageAttAvailable(boolean available)
Set whether failover config has the buildMessage config- Parameters:
available
- true or false
-
-