我想获得以下类型的路由:
- >此时,我想检查来自外部端点的回复是否是包含等于SUCCESS的XML参数的HTTP 200 OK. - >如果是的话,那么我想使用一些存储的参数来构造一个新的HTTP消息(此次方法= PUT)并将其发送到外部端点
我目前遇到的问题如下:
.choice()
.when(simple("${in.headers.CamelHttpResponseCode} == 200"))
// now I want do a few things, eg: check also the XML body via xpath
// and change the message to be sent out (change Method to PUT, ...)
.to("http://myserver.com")
.otherwise()
// if no 200 OK, I want the route to be stopped ... not sure how ?
.end()
Run Code Online (Sandbox Code Playgroud)
问题:如果HTTP响应代码是200 OK,任何想法如何添加这些额外的语句?看起来什么时候不允许我添加额外的语句...(我在Eclipse IDE中出错).
提前致谢.
注意:如果200 OK与"新端点"匹配,然后使用此新端点创建新的路由,我是否必须路由消息?例如:
.choice()
.when(simple("${in.headers.CamelHttpResponseCode} == 200"))
.to("mynewendpoint")
.otherwise()
// if no 200 OK, I want the route to be stopped ... not sure how ?
.end();
from("mynewendpoint").
.setHeader(etc etc)
.to("http://myserver.com")
Run Code Online (Sandbox Code Playgroud)
在后一种情况下,我应该如何定义这个'newendpoint'?
Cla*_*sen 26
在诸如Java之类的编程语言DSL中,您可以一起构建谓词.我几年前发布了一篇关于此的博客文章:http://davsclaus.blogspot.com/2009/02/apache-camel-and-using-compound.html
例如,有两个谓词
Predicate p1 = header("hl7.msh.messageType").isEqualTo("ORM"):
Predicate p2 = header("hl7.msh.triggerEvent").isEqualTo("001");
Run Code Online (Sandbox Code Playgroud)
您可以使用和或或将它们链接在一起.
Predicate isOrm = PredicateBuilder.and(p1, p2);
Run Code Online (Sandbox Code Playgroud)
然后你可以在路线中使用isOrm
from("hl7listener")
.unmarshal(hl7format)
.choice()
.when(isOrm).beanRef("hl7handler", "handleORM")
.otherwise().beanRef("hl7handler", "badMessage")
.end()
.marshal(hl7format);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
18696 次 |
| 最近记录: |