camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tom Ellis <telli...@gmail.com>
Subject Programmatic vs URI based endpoint definition
Date Mon, 02 Sep 2013 20:52:17 GMT
Hi All,

I asked this on stackoverflow [1] and didn't get a response, but this
is obviously a better spot to get questions answered.

Consider the following:

public class MyRouteBuilder extends RouteBuilder {

  @Override
  public void configure() throws Exception {
      FileEndpoint dropLocation = new FileEndpoint();
      dropLocation.setCamelContext(getContext());
      dropLocation.setFile(new File("/data"));
      dropLocation.setRecursive(true);
      dropLocation.setPreMove(".polled");
      dropLocation.setNoop(true);
      dropLocation.setMaxMessagesPerPoll(1);

      from(dropLocation).to(...

versus

public class MyBuilder extends RouteBuilder {

  @Override
  public void configure() throws Exception {
      from("file://data?recursive=true&preMove=.polled&noop=true&maxMessagesPerPoll=1").to(...

Programmatically I get code completion and the like, whereas with the
URI everything is in a single line. I've noticed that the JMX beans
also don't seem to build the URI for stuff like hawt.io if you build
the endpoint with the programmatic way as well. What are the other
pros/cons for each?

Pretty much all the examples I see utilise the URI method - is this
the preferred way?

Could it be possible to use the builder pattern or something to build
up an endpoint, e.g.

FileEndpoint dropLocation = new
FileEndpoint.Builder().camelContext(getContext()).file(new
File("/data")).recursive().preMove().noop().maxMessagesPerPoll(1).build();

Cheers,

Tom Ellis

[1] - http://stackoverflow.com/questions/18361234/what-are-the-pros-cons-when-defining-an-endpoint-as-a-uri-over-defining-it-progr

Mime
View raw message