带有多个HTTP请求和重型处理的REST DSL的行为



大家好,我有一个问题。

我正在使用骆驼休息DSL 用于公开Web服务。此网络服务在 activemq Broker上推出消息,然后骆驼路由进行一些过程,HTTP客户端接收响应。

更好地使用图像

i用:延迟(1000(

模拟重型处理
@**Component
public class TestRouteResponse extends RouteBuilder {
@Override
public void configure() throws Exception {
    restConfiguration().contextPath("/rest-api").apiContextPath("/api-doc")
            .apiProperty("api.title", "Camel REST API").apiProperty("api.version", "1.0")
            .apiProperty("cors", "true").apiContextRouteId("doc-api").bindingMode(RestBindingMode.json);
    rest("/test/{id}").get().description("Get ack nodejs.").route().inOut("activemq:inGenerale");
    from("activemq:inGenerale?concurrentConsumers=25").process(new Dumper()).delay(10000).setBody().constant("30")
            .setHeader(Exchange.HTTP_RESPONSE_CODE, constant(200));
}

但是,当我使用url localhost/test/id调用Web服务两次时,第一个将在10秒后正常响应,而第二个则在20秒后响应。

我认为当第一个URL相同时,第一个途径正在处理时,其余路线已被阻塞。但是这种行为对我来说似乎很奇怪。

如果我使用url localhost/test/id和local -Host/test/id2调用Web服务,两次都没有问题,他们在10秒后都回复。

也许我对骆驼休息DSL路由的行为不了解。

如何在相同的端点上使用相同的URL执行多个呼叫,而无需等待所有先例调用?

谢谢:(

好吧,我找到了解决方案。

我们应该使用帖子而不是进入其余的DSL。

rest("/test/").post("/{id}").description("Get ack nodejs.").route().inOut("activemq:inGenerale");

最新更新