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

Reply via email to