Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache Camel : "direct:start" endpoint - what does it mean?

I'm new to Apache Camel. Can someone explain what "direct:start" means in Camel. Please see

https://camel.apache.org/components/latest/http-component.html

from("direct:start") .to("http://myhost/mypath"); 

Thanks.

like image 908
Soumya Simanta Avatar asked Mar 09 '12 15:03

Soumya Simanta


People also ask

What is Apache Camel DSL?

Camel uses a Java Domain Specific Language or DSL for creating Enterprise Integration Patterns or Routes in a variety of domain-specific languages (DSL) as listed below: Java DSL - A Java based DSL using the fluent builder style. XML DSL A XML based DSL in Camel XML files only.

What is direct and SEDA in Camel?

While the Direct and Direct-VM components take a synchronous approach to joining routes, SEDA does the opposite. It allows routes to be connected in an asynchronous way; that is, when a Camel route publishes a message to a seda: endpoint, the message is sent and control is returned immediately to the calling route.

How do I start Apache Camel route?

Configuring routes to start up laststartupOrder(12345).to("seda:bar"); // use auto assigned startup ordering from("seda:bar").to("mock:other"); In the example above the order of startups of routes should be: seda:foo. direct:start.

How does Apache Camel route work?

A route in Apache Camel is a sequence of steps, executed in order by Camel, that consume and process a message. A Camel route starts with a consumer, and is followed by a chain of endpoints and processors. So firstly, a route receives a message, using a consumer – perhaps from a file on disk, or a message queue.


2 Answers

The "direct:start" above is simply saying that the route starts with a Direct Component named "start".

The direct endpoint provides synchronous invocation of a route. If you want to send an Exchange to the direct:start endpoint you would create a ProducerTemplate and use the various send methods.

ProducerTemplate template = context.createProducerTemplate();  template.sendBody("direct:start", "This is a test message"); 

There is nothing special about the name start. It is simply the name you are going to use when referring to the endpoint and could have just as easily been direct:foo.

like image 60
gregwhitaker Avatar answered Oct 18 '22 05:10

gregwhitaker


Assume like the direct route as a method with name start , so we need to call the start method /direct route to perform certain operation. The below example will help .

The first route will be triggered when an input file is available in XXXX location and when it reaches line , the actual flow will go to second route. Basically the direct route with from endpoint will be triggered by some producer endpoint.

<route id="fileRoute">    <from uri="file:XXXX">       ..    <to uri="direct:start"> </route>  <route id="directStartRoute">     <from uri="direct:start">     <to uri="http://myhost/mypath"> </route> 
like image 35
Panneerselvam Avatar answered Oct 18 '22 06:10

Panneerselvam