1 10 11 package org.mule.routing.outbound; 12 13 import org.mule.config.i18n.Message; 14 import org.mule.config.i18n.Messages; 15 import org.mule.umo.UMOException; 16 import org.mule.umo.UMOMessage; 17 import org.mule.umo.UMOSession; 18 import org.mule.umo.endpoint.UMOEndpoint; 19 import org.mule.umo.routing.CouldNotRouteOutboundMessageException; 20 import org.mule.umo.routing.RoutePathNotFoundException; 21 import org.mule.umo.routing.RoutingException; 22 23 30 31 public class MulticastingRouter extends FilteringOutboundRouter 32 { 33 34 public UMOMessage route(UMOMessage message, UMOSession session, boolean synchronous) 35 throws RoutingException 36 { 37 UMOMessage result = null; 38 if (endpoints == null || endpoints.size() == 0) 39 { 40 throw new RoutePathNotFoundException(new Message(Messages.NO_ENDPOINTS_FOR_ROUTER), message, null); 41 } 42 if (enableCorrelation != ENABLE_CORRELATION_NEVER) 43 { 44 boolean correlationSet = message.getCorrelationId() != null; 45 if (correlationSet && (enableCorrelation == ENABLE_CORRELATION_IF_NOT_SET)) 46 { 47 logger.debug("CorrelationId is already set, not setting Correlation group size"); 48 } 49 else 50 { 51 message.setCorrelationGroupSize(endpoints.size()); 53 } 54 } 55 56 try 57 { 58 UMOEndpoint endpoint; 59 synchronized (endpoints) 60 { 61 for (int i = 0; i < endpoints.size(); i++) 62 { 63 endpoint = (UMOEndpoint)endpoints.get(i); 64 if (synchronous) 65 { 66 if (result == null) 68 { 69 result = send(session, message, endpoint); 70 } 71 else 72 { 73 String def = (String )endpoint.getProperties().get("default"); 74 if (def != null) 75 { 76 result = send(session, message, endpoint); 77 } 78 else 79 { 80 send(session, message, endpoint); 81 } 82 } 83 } 84 else 85 { 86 dispatch(session, message, endpoint); 87 } 88 } 89 } 90 } 91 catch (UMOException e) 92 { 93 throw new CouldNotRouteOutboundMessageException(message, (UMOEndpoint)endpoints.get(0), e); 94 } 95 return result; 96 } 97 } 98 | Popular Tags |