This commit is contained in:
parent
8af3dd780f
commit
4288f99d10
@ -6,22 +6,23 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class DynamicRouterBean {
|
public class DynamicRouterBean {
|
||||||
public String route(String body, @ExchangeProperties Map<String, Object> properties) {
|
public String route(String body, @ExchangeProperties Map<String, Object> properties) {
|
||||||
int invoked = 0;
|
int invoked = (int) properties.getOrDefault("invoked", 0) + 1;
|
||||||
Integer current = (Integer) properties.get("invoked");
|
|
||||||
if (current != null) {
|
|
||||||
invoked = current;
|
|
||||||
}
|
|
||||||
invoked++;
|
|
||||||
properties.put("invoked", invoked);
|
properties.put("invoked", invoked);
|
||||||
|
|
||||||
if (body.equalsIgnoreCase("mock") && invoked == 1) {
|
if (invoked == 1) {
|
||||||
return "mock:dynamicRouter";
|
switch (body.toLowerCase()) {
|
||||||
} else if (body.equalsIgnoreCase("direct") && invoked == 1) {
|
case "mock":
|
||||||
return "mock:directDynamicRouter";
|
return "mock:dynamicRouter";
|
||||||
} else if (body.equalsIgnoreCase("seda") && invoked == 1) {
|
case "direct":
|
||||||
return "mock:sedaDynamicRouter";
|
return "mock:directDynamicRouter";
|
||||||
} else if (body.equalsIgnoreCase("file") && invoked == 1) {
|
case "seda":
|
||||||
return "mock:fileDynamicRouter";
|
return "mock:sedaDynamicRouter";
|
||||||
|
case "file":
|
||||||
|
return "mock:fileDynamicRouter";
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user