I have configured the following route to query my local MongoDB instance. The instance is running on localhost on port 27017 without authentication.
The route is:
from("direct:start")
.to("mongodb:mongoBean?" +
"database=camel-source" +
"&collection=RacingEvents" +
"&operation=getDbStats")
.convertBodyTo(String.class)
.to("file://E:/data/test.txt");
My mongoBean is defined in spring as:
<bean id="mongoBean" class="com.mongodb.Mongo">
<constructor-arg name="host" value="localhost" />
<constructor-arg name="port" value="27017" />
</bean>
The route starts up fine but no data is sent to the file endpoint.
If I replace the direct: component endpoint with a timer: component data is written to the file endpoint:
from("timer://foo?delay=1&repeatCount=1")
.to("mongodb:mongoBean?" +
"database=camel-source" +
"&collection=RacingEvents" +
"&operation=getDbStats")
.convertBodyTo(String.class)
.to("file://E:/data/test.txt");
The question is why does the direct component not initiate the call to MongoDB but the timer component does.