Jboss camel中filter和choice的区别
apachecamel中filter和choice的区别是什么Jboss camel中filter和choice的区别,jboss,apache-camel,enterprise-integration,Jboss,Apache Camel,Enterprise Integration,apachecamel中filter和choice的区别是什么 from("direct:a") .choice() .when(header("foo").isEqualTo("bar")) .to("direct:b") .when(header("foo").isEqualTo("cheese")) .to("direct:c")
from("direct:a")
.choice()
.when(header("foo").isEqualTo("bar"))
.to("direct:b")
.when(header("foo").isEqualTo("cheese"))
.to("direct:c")
.otherwise()
.to("direct:d");
此外,Choice和filter执行相同的操作,其中filter中的其他属性将声明它是否已被过滤
此外,Choice和filter执行相同的操作,其中filter中的其他属性将声明它是否已被过滤
简而言之,过滤器就像一个java
if
语句,例如
if x = 2 {
...
}
骆驼:
.filter(header("foo").isEqualTo("bar"))
...
.end()
.choice()
.when(header("foo").isEqualTo("bar"))
...
.when(header("foo").isEqualTo("chese"))
...
.otherwise()
....
.end()
选择就像java如果。。。如果。。。如果。。。else
语句
if x = 2 {
...
} else if x = 3 {
...
}
骆驼:
.filter(header("foo").isEqualTo("bar"))
...
.end()
.choice()
.when(header("foo").isEqualTo("bar"))
...
.when(header("foo").isEqualTo("chese"))
...
.otherwise()
....
.end()
请注意,
否则
在选项中是可选的
简而言之,过滤器就像一个javaif
语句,例如
if x = 2 {
...
}
骆驼:
.filter(header("foo").isEqualTo("bar"))
...
.end()
.choice()
.when(header("foo").isEqualTo("bar"))
...
.when(header("foo").isEqualTo("chese"))
...
.otherwise()
....
.end()
选择就像java如果。。。如果。。。如果。。。else
语句
if x = 2 {
...
} else if x = 3 {
...
}
骆驼:
.filter(header("foo").isEqualTo("bar"))
...
.end()
.choice()
.when(header("foo").isEqualTo("bar"))
...
.when(header("foo").isEqualTo("chese"))
...
.otherwise()
....
.end()
请注意,
否则
在选项中是可选的
简而言之,选项将根据给定条件路由交换,而过滤器将从交换井中移除某些元素简而言之,选项将根据给定条件路由交换,而筛选器会从exchange中删除某些元素