Hi

See this FAQ
http://camel.apache.org/how-to-use-a-dynamic-uri-in-to.html

On Thu, Nov 13, 2014 at 5:19 AM, James L Greene <jlgree...@aep.com> wrote:
> Just out of curiosity, is there a particular design reason that you can't use 
> variable substitution/dynamic expressions in the defintion of URI's for the 
> camel-metrics component?
>
> Consider the following example.  I'm reading files from a source directory, 
> and want to keep track of the number of records contained in each file.  To 
> pull this off, I need to set header values to override the metric name:
>
> from("file://source").
>    to("metrics:counter:source.document.count").
>    split(body().tokenize("\r\n|\n").
>    to("direct:process");
>
> from("direct:process").
>    setHeater(MetricsConstants.HEADER_METRIC_NAME, 
> simple("source[${header.CamelFileName}].count")).
>    to("metrics:counter:source[].count").
>    ...
>
> If you have a fairly complicated integration route with several metrics to 
> track, this really clutters up the route.  It would be much more desireable 
> to do variable substitution in the URI itself, like this:
>
> from("direct:process").
>    to("metrics:counter:source[${header.CamelFileName}].count").
>    ...
>
> I'm just curious as to whether a future rev of the component might be able to 
> eliminate the use of Headers to override the name portion of the URI.  From a 
> design perspective, would moving the metric name to a parameter make this any 
> easier to accomplish?  For example:
>
> from("direct:process").
>    to("metrics:counter?name=source[${header.CamelFileName}].count").
>    ...
>
> Either way, this component is really helping out with a requirement for my 
> current project!



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cib...@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Reply via email to