Jms 在Camel中生成SOAP响应

Jms 在Camel中生成SOAP响应,jms,apache-camel,activemq,Jms,Apache Camel,Activemq,我在Camel(使用cxf)中创建了一个web服务流,它公开了一个简单的web服务。但是,它需要与外部系统集成,外部系统以XML(EXT.OUTqque)的形式接收SOAP请求的一部分,并通过XML(EXT.inqueue)进行响应,如下图所示 我无法控制外部系统的行为,但我希望确保基于从EXT.IN queue获得的响应生成SOAP响应(即从XML生成) 到目前为止,我的流程如下所示: from("cxf:bean:myCamelWSEndpoint") // #1 .transform

我在Camel(使用cxf)中创建了一个web服务流,它公开了一个简单的web服务。但是,它需要与外部系统集成,外部系统以XML(EXT.OUTqque)的形式接收SOAP请求的一部分,并通过XML(EXT.inqueue)进行响应,如下图所示

我无法控制外部系统的行为,但我希望确保基于从EXT.IN queue获得的响应生成SOAP响应(即从XML生成)

到目前为止,我的流程如下所示:

from("cxf:bean:myCamelWSEndpoint") // #1
  .transform().simple("${in.body[0]}") // #2 get Body object
  .process(soapToXmlProcessorRef) // #3 Processor that sets the exchange.out.body to some xml snippet
  .to(ExchangePattern.InOut, "activemq:queue:EXT.OUT") // #4 sends XML to EXT.OUT queue
  .process(xmlToSoapProcessorRef) // #5 Processor that generates SOAP response object from incoming XML snippet
[                          main] route2 INFO  Send message to EXT.OUT
[                          main] route2 INFO  Wait until message from EXT.IN is received and enrich
[read #0 - JmsConsumer[EXT.OUT]] route1 INFO  Received message from EXT.OUT and sent it to EXT.IN: Hello, World!
[                          main] route2 INFO  Finally: I was on the moon!
我已经通过创建一个模拟EXT.OUT队列测试了流的其余逻辑,该队列只生成XML并返回它

我想知道如何指定它等待在上述步骤4和步骤5之间发送到EXT.IN queue的响应

非常感谢您的帮助。谢谢

使用
pollEnrich(“activemq:queue:EXT.IN”)

简化测试路线:

from("activemq:queue:EXT.OUT")
    .log("Received message from EXT.OUT and sent it to EXT.IN: ${body}")
    .setBody(constant("I was on the moon!"))
    .to("activemq:queue:EXT.IN");

from("direct:start")
    .log("Send message to EXT.OUT")
    .to("activemq:queue:EXT.OUT") // sends XML to EXT.OUT queue
    .log("Wait until message from EXT.IN is received and enrich")
    .pollEnrich("activemq:queue:EXT.IN")
    .log("Finally: ${body}");
开始路线:

final ProducerTemplate template = context.createProducerTemplate();
template.sendBody("direct:start", "Hello, World!");
输出应如下所示:

from("cxf:bean:myCamelWSEndpoint") // #1
  .transform().simple("${in.body[0]}") // #2 get Body object
  .process(soapToXmlProcessorRef) // #3 Processor that sets the exchange.out.body to some xml snippet
  .to(ExchangePattern.InOut, "activemq:queue:EXT.OUT") // #4 sends XML to EXT.OUT queue
  .process(xmlToSoapProcessorRef) // #5 Processor that generates SOAP response object from incoming XML snippet
[                          main] route2 INFO  Send message to EXT.OUT
[                          main] route2 INFO  Wait until message from EXT.IN is received and enrich
[read #0 - JmsConsumer[EXT.OUT]] route1 INFO  Received message from EXT.OUT and sent it to EXT.IN: Hello, World!
[                          main] route2 INFO  Finally: I was on the moon!

如果您收到响应或出现超时(默认值为20秒),则路由将在步骤#5中继续处理您的交换。据我所知,它已经满足了你的要求。