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