首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Spring集成HTTP

Spring集成HTTP
EN

Stack Overflow用户
提问于 2014-12-22 05:41:26
回答 1查看 814关注 0票数 0

支持。嗨,我正在尝试基于路径属性的通道路由。例如,如果配置如下

我想根据路径将消息发送到不同的通道,即path=“网关/搜索”值。查看了基于头的路由和有效负载类型路由。你能建议一下实施的方法吗?

代码语言:javascript
复制
<!-- Inbound/Outbound Channels -->
<int:channel id="ServiceSearchRequest" />
<int:channel id="ServiceSearchResponse" />


<int-http:inbound-gateway id="inboundEmployeeSearchRequestGateway"
    supported-methods="GET, POST" request-channel="ServiceSearchRequest"
    reply-channel="ServiceSearchResponse"
    mapped-response-headers="Content-Type" 
    path="ieg/Service/search" request-payload-type="java.lang.String"
    reply-timeout="5000">
</int-http:inbound-gateway>

<int-http:outbound-gateway request-channel="ServiceSearchRequest"
    reply-channel="ServiceSearchResponse"
    url="http://localhost:8080/proj/Service/avgWaitTime123.json"
    http-method="POST" expected-response-type="java.lang.String"
    mapped-response-headers="Content-Type"  />

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-12-22 13:42:38

不清楚您想要什么;您只有一个path (ieg/dataService/search),所以如果您在路径上路由,所有消息都会转到单个通道。

如果您的意思是您想要根据某个查询字符串参数..?foo=bar进行路由,那么您可以向入站网关添加一个<header/>元素来捕获它作为一个标头。

代码语言:javascript
复制
<int-http:header name="foo" expression="#requestParams.foo.get(0)" />

然后可以使用报头值路由器。有关头表达式可用变量的完整列表,请参见参考文献 (向下滚动到URI Template Variables and Expressions )。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27597100

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档