Apache camel 驼峰:确定实际响应与原始请求
我有下面的方法来复制一个非常基本的场景,但可能停留在一个概念上Apache camel 驼峰:确定实际响应与原始请求,apache-camel,eip,Apache Camel,Eip,我有下面的方法来复制一个非常基本的场景,但可能停留在一个概念上 this.from("direct:start") .process(exchange -> { exchange.getMessage().setBody("modified", String.class); exchange.getMessage().setHeader("x", "y");
this.from("direct:start")
.process(exchange -> {
exchange.getMessage().setBody("modified", String.class);
exchange.getMessage().setHeader("x", "y");
})
.to("mock:destination")
.process(exchange -> {}); //here is the problem
现在我像往常一样有两种目的地
- 请求回复
@EndpointInject(uri = "mock:destination")
protected MockEndpoint mockProperResponseMaker;
this.mockProperResponseMaker.whenAnyExchangeReceived(exchange -> {
exchange.getMessage().setBody("response");
exchange.getMessage().setHeader("a", "b");
});
现在,在最后一个处理器中,我得到了作为“response”的inbody和作为null的outbody
- 仅单向请求
@EndpointInject(uri = "mock:destination")
protected MockEndpoint mockNoResponseMaker;
//no whenAnyExchangeReceived() here
现在在最后一个处理器中,我得到的是“modified”的inbody和null的outbody
我的问题是如何识别这两种情况,即在最后一个处理器中,我想确定是交换包含来自端点的实际响应,还是它的“我的请求”主体作为请求发送到端点,而不知道目标类型(在应用程序的这一部分,我不知道有人会将哪种端点定义为目标)
对此有何想法,请提出建议。提前谢谢