Reputation: 1022
I'm using Camel 2.13.1 and have a weird behaviour. If I want to test my routes I've written in XML.
I always get the message on one route that no consumers are available. If I deploy this on Tomcat everything is working fine. Even on startup I can see the log that clearly states that the route is consumed.
My routes looks like that:
<route id="demo-polling-consumer">
<from uri="timer:demo-polling?fixedRate=true&period=60s" />
<to uri="bean:demo?method=selectDemoCustomer" />
<to uri="direct-vm:demo-get-new-orders" />
<split>
<simple>${body}</simple>
<to uri="direct-vm:demo-get-order-details" />
</split>
</route>
<route id="epunkt-get-new-jobadverts">
<from uri="direct-vm:demo-get-order-details" />
<to uri="bean:demo?method=getOrderDetail" />
</route>
I start the test like that:
@RunWith(SpringJUnit4ClassRunner.class)
@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
@ContextConfiguration(locations = { "classpath:spring-module.xml" })
public class FirstBirdContextTest {
@EndpointInject(uri = "mock:out")
private MockEndpoint mockOut;
@Produce(uri = "direct:in")
private ProducerTemplate in;
@Test
public void testPayloadIsTransformed() throws InterruptedException, FileNotFoundException, JAXBException {
}
I basically just start my spring-context. The spring-module.xml loads multiple camel-context.xml files.
The error says:
org.apache.camel.component.directvm.DirectVmConsumerNotAvailableException: No consumers available on endpoint: Endpoint[direct-vm:demo-get-order-details]. Exchange[Message: [[Ljava.lang.Object;@6dd62653]]
The startup log says
[ main] SpringCamelContext INFO Route: orderdetails started and consuming from: Endpoint[direct-vm:demo-get-order-details]
Again. If I deploy that on tomcat everything works fine.
Upvotes: 1
Views: 7192
Reputation: 23352
Setting block=true
when calling your target route may solve that issue, i.e.
<to uri="direct-vm:demo-get-order-details?block=true" />
Now I rather assume that it was just coincidence that it was working on the server and that there might have been a small chance that it would also have given the same error on the server, namely when the server is starting up and the target route isn't yet available. Usually that will not really happen... but it could, so a block on your target route may be worth it nonetheless.
Upvotes: 0
Reputation: 55540
This route should have a from, that is currently missing
<route id="epunkt-get-new-jobadverts">
<to uri="direct-vm:demo-get-order-details" />
<to uri="bean:demo?method=getOrderDetail" />
</route>
Upvotes: 0