user2824073
user2824073

Reputation: 2485

Clarification about Camel direct component

I can see that many Camel route examples are initiated with a "direct" component. For example:

<camelContext xmlns="http://camel.apache.org/schema/spring">
  <route id="myroute">

 <from uri="direct:start"/>
      <setBody>
        <simple>Hello World!</simple>
      </setBody>

    <log message="${body}"/>  

    <to uri="mock:result"/>
  </route>
</camelContext>

However, by running a route like this (mvn camel:run) the route is not started and Camel keeps hanging forever. Is it not meant to be used directly this kind the direct component? Thanks

Upvotes: 0

Views: 673

Answers (1)

Claus Ibsen
Claus Ibsen

Reputation: 56082

Its not hanging. You need to send a message to the direct endpoint before its routed. eg like in java code to do a direct method invocation from a client by calling a java method.

Instead of direct you can use a timer if you want to route a message automatic every X time etc.

To send a message to the direct endpoint (or any other Camel endpoint) then read about the producer template. For example from the getting started guide: http://camel.apache.org/walk-through-an-example.html

Upvotes: 1

Related Questions