Hey guys, question about some camel functionality. Java version: jdk1.8.0_152 Karaf version: 4.3.2 (I also tested 4.3.7, and it has the same odd behavior) Camel version: 3.11.0 (I also tested 3.14.0, and it has the same odd behavior)
In a clean karaf install, I created two different bundles. TestService1 and TestService2. TestService1 sends message to TestService2, then TestService2 uses producerTemplate to hit a route on TestService1. That producerTemplate call appears to get stuck forever on an internal block. If I do the same call without using producerTemplate (aka with to() or Recipient List), it works fine. This did work in karaf 4.1.5 & camel 2.21.0, but appears to have stopped functioning when I tried the versions stated above. I guess my question here is, is this a bug? Or is this some sort of functionality to prevent looping routes. It only seems to happen if it's two separate bundles (and thus separate camel contexts) so I'd guess this is a bug, but I'm unsure. If anyone happens to know any way around this possible issue as well, that'd be great to know. The only ways I've found is calling producerTemplate in a new thread (not a good solution), or just outright avoiding the use of producerTemplate (even worse solution). Stack trace when I forcibly killed the thread: ======================== Caused by: java.lang.InterruptedException at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:998) at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1304) at java.util.concurrent.CountDownLatch.await(CountDownLatch.java:231) at org.apache.camel.impl.engine.DefaultAsyncProcessorAwaitManager.await(DefaultAsyncProcessorAwaitManager.java:107) at org.apache.camel.impl.engine.DefaultAsyncProcessorAwaitManager.process(DefaultAsyncProcessorAwaitManager.java:85) at org.apache.camel.impl.engine.SharedCamelInternalProcessor.process(SharedCamelInternalProcessor.java:108) at org.apache.camel.support.cache.DefaultProducerCache.send(DefaultProducerCache.java:190) at org.apache.camel.impl.engine.DefaultProducerTemplate.send(DefaultProducerTemplate.java:176) at org.apache.camel.impl.engine.DefaultProducerTemplate.send(DefaultProducerTemplate.java:172) at org.apache.camel.impl.engine.DefaultProducerTemplate.send(DefaultProducerTemplate.java:137) Code: ======================== classes: public class TestService1 extends RouteBuilder { private static final Logger logger = LoggerFactory.getLogger(TestService1.class); public static final String TEST_SERVICE2_ROUTE = "direct-vm://testService2Route"; public static final String TEST_SERVICE1_RETURN_ROUTE = "direct-vm://testService1ReturnRoute"; @Override public void configure() throws Exception { // On startup, send message to second jar/camel context from("timer://startup?repeatCount=1&delay=30s") .routeId("startup") .to(TEST_SERVICE2_ROUTE); // Listens for return call from second jar from(TEST_SERVICE1_RETURN_ROUTE).routeId("testService1ReturnRoute") .bean(this, "returnedMethod"); } public void returnedMethod() { logger.info("Made it back to the first jar!!!!!!!"); } } public class TestService2 extends RouteBuilder { private static final Logger logger = LoggerFactory.getLogger(TestService2.class); public static final String TEST_SERVICE2_ROUTE = "direct-vm://testService2Route"; public static final String TEST_SERVICE1_RETURN_ROUTE = "direct-vm://testService1ReturnRoute"; @Produce(TEST_SERVICE1_RETURN_ROUTE) ProducerTemplate executor; @Override public void configure() throws Exception { //listens for a call from service 1, then hits a route in service 1 from(TEST_SERVICE2_ROUTE).routeId("testService2Route") .bean(this, "hitService1"); } public void hitService1() { logger.info("This call gets locked up"); executor.sendBody("hello"); } } blueprints: <?xml version="1.0" encoding="UTF-8"?> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd"> <bean id="testService2" class="com.example.test2.TestService2"></bean> <!-- Camel --> <camelContext id="camel" xmlns="http://camel.apache.org/schema/blueprint"> <routeBuilder ref="testService2"/> </camelContext> </blueprint> <?xml version="1.0" encoding="UTF-8"?> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd"> <bean id="testService1" class="com.example.test1.TestService1"></bean> <!-- Camel --> <camelContext id="camel" xmlns="http://camel.apache.org/schema/blueprint"> <routeBuilder ref="testService1"/> </camelContext> </blueprint>