我想将 web 服务请求路由到 jms 队列的 InOnly 端点。然后将从单独的 InOnly 端点接收到的响应 jms 消息路由回 Web 服务客户端作为响应。Web 服务请求/响应是同步的 InOut 模式,子路由是异步的。我有哪些选择可以使用 Camel 实现这一目标?
这里的骆驼路线是用来解释我的问题的:
String uri={webserice uri}
from(uri)
.process(new Processor() {
public void process(Exchange exchange) throws Exception {
ServcieRequest req =
exchange.getIn().getBody(ServcieRequest.class);
// One option to me is to spawn another route here to route to jms queue...
ProducerTemplate template = exchange.getContext().createProducerTemplate();
template.sendBodyAndHeaders("jms:queue:INQueue", req.getPayload(), headers);
// then need to wait ...until received jms response from the route below
}});
from("jms:queue:OUTQueue")
.process(new Processor() {
public void process(Exchange exchange) throws Exception {
// received jms response message
// need to update the exchange data in the above route based on jms message
// so the final response to the webservice cilent can receive the data ...
}});