On 06/02/15 02:14, Claus Ibsen wrote:
On Wed, Feb 4, 2015 at 11:17 AM, Jan Matèrne (jhm) <apa...@materne.de> wrote:
The URI is just a string.
Why not extract your "builder" into a simple utility method

public class EndpointUtils {
     public static String rabbitEndpoint(String scheme, String host, String 
host) {
         ...
     }
}

With SpringDSL property placeholder come into mind ...

Right, the use of placeholders mean the "builder" can be statically defined. Here's the static method we've come up with:

    String rmq(String amqpExchange, final String... params) {
        return "rabbitmq://{{rabbitmq.host}}:{{rabbitmq.port}}/"
                + amqpExchange + "?"
                + "username={{rabbitmq.username}}&"
                + "password=RAW({{rabbitmq.password}})"
                + (params.length > 0 ?
                    "&" + String.join("&", params) :
                    "");
    }

Then use it like so:


        from(rmq("profile-import",
                 "autoDelete=false",
                 "queue=foo",
                 "exchangeType=topic"))
            .log("${in.body}")



Yeah although Camel 2.15 offers the ability for us to generate the
source code for those builders, as each component has information
about each of their options.


Ok, I think this is definitely worth looking into.


But on the other hand, many people use the Camel components using
configuration and uris only ... you can use the FTP component
without even have it on the classpath at development time

It didn't occur to me that this was a design goal. It makes sense but I
would never take advantage of it because I want new routes to go
through a standard build/deploy/test pipeline.



-----Ursprüngliche Nachricht-----
Von: Nathan Jones [mailto:nat...@ncjones.com]
Gesendet: Mittwoch, 4. Februar 2015 10:55
An: users@camel.apache.org
Betreff: Patterns for DRY Camel endpoints

Is there a standard pattern for defining Camel endpoints so that
commonly used endpoint settings do not need to be repeated in every
endpoint definition?

Reply via email to