Search code examples
javaapache-camel

How to stop thread of jms in apache camel


How can I stop a thread in apache camel when I use jms for consuming an Ibm Mq? I'm consuming a jms and later I have to consume and Rest api, but I got errors of time out because the thread of jms continues, when is not necessary for the consume of the rest api. This is my route:

from(Rutas.CONSUME_CUENTA_DETALLE)
        .routeId("CONSUME_CUENTA_DETALLE")
            .removeHeaders("*")
            .setHeader("CamelJmsDestinationName",
                    constant("queue:///"+colaCuentaDetalle+"?targetClient=1"))
            .to("jms://queue:" + colaCuentaDetalle
                    +"?exchangePattern=InOut"
                    +"&useMessageIDAsCorrelationID=true"
                    +"&replyToType=Temporary"
                    +"&requestTimeout=3s"
                    +"&asyncStopListener=true"
                    +"&cacheLevelName=CACHE_CONSUMER")
            .id("Cuenta_detalle")
            .removeHeader("*")
            .to(Rutas.VALIDATE_RESPONSE_CUENTA_DETALLE)
        .end();

Solution

  • I can't see what type of consumer is at Rutas.VALIDATE_RESPONSE_CUENTA_DETALLE, but if you make it a SEDA consumer, it will use its own thread pool to handle messages, returning the JMS consumer thread back to its own pool.