apache-camel - Camel - 基于 HTTP 请求内容的重定向
问题描述
我正在尝试使用骆驼根据请求正文的内容重定向 http 请求。
我已经创建了一个用于接收 http 请求的端点,并且我能够使用以下路由成功地将我的请求重定向到不同的 URL;
<route>
<from uri="servlet:myapptest2?matchOnUriPrefix=true"/>
<to uri="http://sampleurl/test?bridgeEndpoint=true&throwExceptionOnFailure=false" />
</route>
但我无法找到检查 http 请求正文的方法。我的 HTTP 请求将具有与此类似的 JSON 正文;
{
"testLoginRequest": {
"sampleData1": [{
"key1": "val1",
"key2": "val2"
}],
"sampleData2": [{
"key1": "val1",
"key2": "val2"
}]
}
}
如果 JSON 包含值“testLoginRequest”,我想将请求重定向到特定 URL。我读到这应该是可能的;
from("direct:test").
choice().
when(body().contains("javainuse1"))
.to("jms:queue:javainuse1").
otherwise().
to("jms:queue:otherwise");
由于我必须使用 XML DSL,我尝试实现以下路由,但它似乎不起作用;
<route>
<from uri="servlet:myapptest3?matchOnUriPrefix=true" />
<choice>
<when>
<simple>${body} contains 'testLoginRequest' </simple>
<to uri="http://sampleurlforlogin/test?bridgeEndpoint=true&throwExceptionOnFailure=false" />
</when>
</choice>
</route>
我是否遵循正确的方法。我在这里做错了什么?
解决方案
推荐阅读
- r - 使用 RSTUDIO 对 SpaceX 工作进行网络抓取
- python - 如何使用 dask 从 S3 读取 csv 文件并提及我的访问密钥和秘密?
- c++ - 使用 /clr:netcore 从非托管 C++ 调用 .dll 构建
- angular - 使用角度材质网格列表时如何避免水平滚动条?
- javascript - 使用“Ctrl+A”全选并删除输入字段的内容
- docker - 在 docker 中附加卷后找不到模块
- swift - Swift Firestore 分页正在检索下一批文档但替换第一批
- javascript - 使用Javascript为对象数组中的每个对象添加一个递增的数字
- jquery - 你可以在 fadeIn Jquery 之后嵌入 SVG 的链接吗?
- sql - 不明确的列名“Created_Date”?