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 ... Having special builders sound also fine, but a lot of work as it requires one builder per endpoint ... Jan > -----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? For example, every RabbitMQ endpoint I declare > always repeats the same connection settings like the following: > > > rabbitmq://{{rabbitmq.host}}:{{rabbitmq.port}}/exchange?username=... > > I'm thinking of having an (immutable) endpoint URL builder that can be > reused by all route builders. Then I would only need to set the common > connection settings once (say, in my Spring configuration): > > @Bean > UrlBuilder rmqEndpointUrlBuilder() { > return new UrlBuilder() > .setScheme("rabbitmq") > .setHost("{{rabbitmq.host}}") > .setPort("{{rabbitmq.port}}"); > } > > > That URL builder would be injected into my Camel route builder and can > be used like so: > > from(rmqEndpointUrlBuilder.setPath("/exchange").toString()) > > Does this sound reasonable? Is there a simpler way to achieve this? > > Taking the endpoint builder idea further may be interesting. If there > were endpoint builders specific to each component type then it would be > a lot easier to define endpoint URL parameters. Has this sort of thing > been considered before? > > - Nathan