我有一个使用Jersey REST组件的mule流程
<flow name="rest-api" doc:name="rest-api">
<http:inbound-endpoint exchange-pattern="request-response"
host="localhost" path="rest" port="8081" doc:name="HTTP" />
<logger message="Message !!!!!!!! #[payload]" level="INFO"
doc:name="Logger" />
<jersey:resources doc:name="REST">
<component class="com.test.api.TestAPI" />
</jersey:resources>
<logger message="Message $$$$$$$ #[payload]" level="INFO" doc:name="Logger" />
</flow>
Run Code Online (Sandbox Code Playgroud)
过去的球衣组件的对象是"org.mule.module.jersey.MuleResponseWriter"类型
如何处理这个有效载荷?我需要使用该消息并在返回调用者之前对消息进行一些处理.
参考:http://www.mulesoft.org/documentation/display/current/Jersey+Module+Reference
发送泽西对其他流量的响应
如果您想要将您的球衣组件的请求转换或发送到下一个资源/流程,那么您需要使用
ContainerResponse cr = (ContainerResponse) message.getInvocationProperty("jersey_response");
String messageString = (String) cr.getResponse().getEntity();
message.setPayload(messageString);
Run Code Online (Sandbox Code Playgroud)
这会将org.mule.module.jersey.MuleResponseWriter $ 1类型转换为String,您可以将其转发到下一个资源.
注意:OP已经对这个问题进行了彻底的审查(见历史记录),所以这个答案现在看起来已经断开了.这个答案解释了Jersey资源如何与其他流程进行交互.
要从资源调用其他流,您可以:
MuleContextAware然后使用MuleClient执行调用.这是APIkit正在解决的问题之一:http://www.mulesoft.org/documentation/display/current/APIkit
| 归档时间: |
|
| 查看次数: |
1940 次 |
| 最近记录: |