log.debug("Failover Endpoint : " + getName()); if (getChildren().isEmpty()) { informFailure(synCtx, SynapseConstants.ENDPOINT_FO_NONE_READY, "FailoverLoadbalance endpoint : " + getName() + " - no child endpoints"); return; evaluateProperties(synCtx); for (Endpoint endpoint : getChildren()) { if (endpoint.readyToSend()) { foundEndpoint = true; (getName() != null ? getName() : SynapseConstants.ANONYMOUS_ENDPOINT) + " - no ready child endpoints"; log.warn(msg); informFailure(synCtx, SynapseConstants.ENDPOINT_FO_NONE_READY, msg); currentEndpoint = getChildren().get(0); for (Endpoint endpoint : getChildren()) { if (endpoint.readyToSend()) { foundEndpoint = true; (getName() != null ? getName() : SynapseConstants.ANONYMOUS_ENDPOINT) + " - no ready child endpoints"; log.warn(msg); informFailure(synCtx, SynapseConstants.ENDPOINT_FO_NONE_READY, msg);
if (failoverElement != null) { FailoverEndpoint failoverEndpoint = new FailoverEndpoint(); failoverEndpoint.setName(name); String msg = "Invalid Synapse configuration.\n" + "A FailOver must have child elements, but the FailOver " + "'" + failoverEndpoint.getName() + "' does not have any child elements."; log.error(msg); throw new SynapseException(msg); failoverEndpoint.setChildren(getEndpoints(failoverElement, failoverEndpoint, properties)); failoverEndpoint.setDynamic(false);
public boolean readyToSend() { if (getContext().isState(EndpointContext.ST_OFF)) { return false; } for (Endpoint endpoint : getChildren()) { if (endpoint.readyToSend()) { currentEndpoint = endpoint; return true; } } return false; }
public void onChildEndpointFail(Endpoint endpoint, MessageContext synMessageContext) { logOnChildEndpointFail(endpoint, synMessageContext); if (!((AbstractEndpoint)endpoint).isRetryDisabled(synMessageContext)) { if (log.isDebugEnabled()) { log.debug(this + " Retry Attempt for Request with [Message ID : " + synMessageContext.getMessageID() + "], [To : " + synMessageContext.getTo() + "]"); } send(synMessageContext); } else { String msg = "Failover endpoint : " + (getName() != null ? getName() : SynapseConstants.ANONYMOUS_ENDPOINT) + " - one of the child endpoints encounterd a non-retry error, " + "not sending message to another endpoint"; log.warn(msg); informFailure(synMessageContext, SynapseConstants.ENDPOINT_FO_NONE_READY, msg); } }
public void send(MessageContext synCtx) { if (RuntimeStatisticCollector.isStatisticsEnabled()) { java.lang.Integer currentIndex = null; boolean retry = (synCtx.getProperty(SynapseConstants.LAST_ENDPOINT) != null); if ((getDefinition() != null) && !retry) { currentIndex = OpenEventCollector.reportChildEntryEvent(synCtx, getReportingName(), ComponentType.ENDPOINT, getDefinition().getAspectConfiguration(), true); } try { sendMessage(synCtx); } finally { if (currentIndex != null) { CloseEventCollector.closeEntryEvent(synCtx, getReportingName(), ComponentType.MEDIATOR, currentIndex, false); } } } else { sendMessage(synCtx); } }
logSetter(); if (log.isDebugEnabled()) { log.debug("Failover Endpoint : " + getName()); if (getContext().isState(EndpointContext.ST_OFF)) { informFailure(synCtx, SynapseConstants.ENDPOINT_FO_NONE_READY, "Failover endpoint : " + getName() != null ? getName() : SynapseConstants.ANONYMOUS_ENDPOINT + " - is inactive"); return; buildMessage(synCtx); buildMessage(synCtx); if (getChildren().isEmpty()) { informFailure(synCtx, SynapseConstants.ENDPOINT_FO_NONE_READY, "FailoverLoadbalance endpoint : " + getName() + " - no child endpoints"); return; evaluateProperties(synCtx); for (Endpoint endpoint : getChildren()) { if (endpoint.readyToSend()) { foundEndpoint = true; (getName() != null ? getName() : SynapseConstants.ANONYMOUS_ENDPOINT) + " - no ready child endpoints"; log.warn(msg); informFailure(synCtx, SynapseConstants.ENDPOINT_FO_NONE_READY, msg);
if (failoverElement != null) { FailoverEndpoint failoverEndpoint = new FailoverEndpoint(); failoverEndpoint.setName(name); String msg = "Invalid Synapse configuration.\n" + "A FailOver must have child elements, but the FailOver " + "'" + failoverEndpoint.getName() + "' does not have any child elements."; log.error(msg); throw new SynapseException(msg); failoverEndpoint.setChildren(getEndpoints(failoverElement, failoverEndpoint, properties)); failoverEndpoint.setDynamic(false); failoverEndpoint.setBuildMessageAttAvailable(true); if (JavaUtils.isTrueExplicitly(buildMessageAtt)) { failoverEndpoint.setBuildMessageAtt(true);
if (failoverEndpoint.isBuildMessageAtt()) { failoverElement.addAttribute(XMLConfigConstants.BUILD_MESSAGE, Boolean.toString(failoverEndpoint.isBuildMessageAtt()), null); for (Endpoint childEndpoint : failoverEndpoint.getChildren()) { failoverElement.addChild(EndpointSerializer.getElementFromEndpoint(childEndpoint)); if (!failoverEndpoint.isDynamic()) { failoverElement.addAttribute("dynamic", "false", null);
public boolean readyToSend() { for (Endpoint endpoint : getChildren()) { if (endpoint.readyToSend()) { currentEndpoint = endpoint; return true; } } return false; }
for (Endpoint childEndpoint : failoverEndpoint.getChildren()) { failoverElement.addChild(EndpointSerializer.getElementFromEndpoint(childEndpoint)); if (!failoverEndpoint.isDynamic()) { failoverElement.addAttribute("dynamic", "false", null);
/** * Build the message * @param synCtx Synapse Context */ private void buildMessage(MessageContext synCtx) { try { RelayUtils.buildMessage(((Axis2MessageContext) synCtx).getAxis2MessageContext()); } catch (IOException | XMLStreamException ex) { handleException("Error while building the message", ex); } } }
public void onChildEndpointFail(Endpoint endpoint, MessageContext synMessageContext) { //If there is a failure in child endpoint, restore the original message envelope from the message context if (synMessageContext.getProperty(SynapseConstants.LB_FO_ENDPOINT_ORIGINAL_MESSAGE) != null) { try { synMessageContext.setEnvelope( (SOAPEnvelope) synMessageContext.getProperty(SynapseConstants.LB_FO_ENDPOINT_ORIGINAL_MESSAGE)); } catch (AxisFault ex) { log.error("Couldn't restore the original message to the failover endpoint", ex); } } logOnChildEndpointFail(endpoint, synMessageContext); if (((AbstractEndpoint)endpoint).isRetry(synMessageContext)) { if (log.isDebugEnabled()) { log.debug(this + " Retry Attempt for Request with [Message ID : " + synMessageContext.getMessageID() + "], [To : " + synMessageContext.getTo() + "]"); } send(synMessageContext); } else { String msg = "Failover endpoint : " + (getName() != null ? getName() : SynapseConstants.ANONYMOUS_ENDPOINT) + " - one of the child endpoints encounterd a non-retry error, " + "not sending message to another endpoint"; log.warn(msg); informFailure(synMessageContext, SynapseConstants.ENDPOINT_FO_NONE_READY, msg); } }
List addresses = endpoint.getChildren(); assertEquals("There should be 3 leaf level address endpoints", addresses.size(), 3);
List children2 = failoverEndpoint.getChildren();
List addresses = endpoint.getChildren(); assertEquals("There should be 3 leaf level address endpoints", addresses.size(), 3);
List children2 = failoverEndpoint.getChildren();