【发布时间】:2014-08-06 23:55:26
【问题描述】:
我正在尝试使用选择路由器根据其路径处理 HTTP 消息。这很有效,直到我遇到使用 PUT 方法提交消息并且路径的尾随部分是 customerID 的情况。所以我有一个类似这样的路径:services/v1/customer/{custNo}。在我的选择路由器中:
<choice doc:name="Route Message By Path">
<when expression="message.inboundProperties['http.relative.path'] == 'services/v1/users'">
<flow-ref name="NewUser" doc:name="New User"/>
</when>
<when expression="message.inboundProperties['http.relative.path'] == 'services/v1/users/{userID}'">
<flow-ref name="UpdateUser" doc:name="Update User"/>
</when>
<when expression="message.inboundProperties['http.relative.path'] == 'services/v1/emails'">
<flow-ref name="CaptureEmail" doc:name="Capture Email"/>
</when>
<when expression="message.inboundProperties['http.relative.path'] == 'services/v1/taxes'">
<flow-ref name="Taxes" doc:name="Taxes"/>
</when>
<otherwise>
<logger message="The path submitted is unknown. Submitted path is: #[message.inboundProperties['http.relative.path']]" level="INFO" doc:name="Unknown path"/>
<set-payload value="The path submitted is unknown. Submitted path is: #[message.inboundProperties['http.relative.path']]" doc:name="Set Payload"/>
<http:response-builder status="500" contentType="text/plain" doc:name="HTTP Response Builder"/>
</otherwise>
</choice>
我使用 rest 和带注释的 java 类来完成这项工作,但如果可以的话,我宁愿保持简单并在 mule 组件中。有没有办法在路由器的 MEL 中通配路径?另外,如果继续使用选择路由器,是否有一种从路径中提取客户编号的好/简单的方法?
【问题讨论】: