我正在开发基于 web 服务和 jms 队列的 Camel 动态路由管理器。我有以下架构:
endpoint:cxf -> jms:queue -> dynamic routing to a jms:queue -> processing
这是我的路线定义:
@Override
public void configure() throws Exception {
routeDefinition = from(fromEndpoint).routeId(name)
.dynamicRouter(method(DynamicRoutingManager.class, "getRoute")).process(exchange -> {
final List<?> soaList = exchange.getIn().getBody(List.class);
final String type = (String) soaList.get(0);
final String documentNumber = (String) soaList.get(1);
final String productionStepNumber = (String) soaList.get(2);
final String message = (String) soaList.get(3);
final String messageToSend = "Route ID=" + name + ", from=" + fromEndpoint + ", type=" + type
+ ", document number=" + documentNumber + ", production step number" + productionStepNumber
+ ", message=" + message;
LOG.debug("==> message={}", messageToSend);
exchange.getOut().setBody(messageToSend);
}); // .to(DLQ);
}
这里是我的动态路由管理器(我保持简单):
public String getRoute(String body, @Header(Exchange.SLIP_ENDPOINT) String previous) {
LOG.debug("========> BODY={}", body);
return "jms:topic:urgent_doc1_prod1";
}
路由jms:topic:urgent_doc1_prod1
在运行时定义并运行(在日志中查看)
事实是当我发送这样的请求时(见下文)我收到超时错误......
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:hel="http://cxf.apache.org/wsse/handler/helloworld">
<soapenv:Header/>
<soapenv:Body>
<hel:message>
<!--Optional:-->
<type>urgent</type>
<!--Optional:-->
<document_number>1</document_number>
<!--Optional:-->
<production_step_number>1</production_step_number>
<!--Optional:-->
<message>un message</message>
</hel:message>
</soapenv:Body>
</soapenv:Envelope>
因为我认为我的消息没有转发到第二个 jms:queue,所以可以进行任何处理......
我做错了什么?