You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Doug Douglass <do...@gmail.com> on 2013/03/08 22:33:54 UTC

dynamic URI parameter in from URI?

I'm familiar with dynamic to URI support in Camel[1], but I'm looking for
ways to dynamically set the from URI or at least update a parameter in a
from URI.

Specifically, I'm using the Atom component to access a paged feed and want
to follow "next" links to consume the entire feed (could total thousands to
tens of thousands of entries) and then poll the feed. I'm currently using
Camel 2.10.2, but can switch to any version if need be. Note that the Atom
service I'm testing returns HTTP 304 if the "next" link has no updated
entries; perhaps I should switch gears and use Timer and HTTP/HTTP4
components and do my own processing via Abdera...

Any tips are appreciated.

Doug

[1] http://camel.apache.org/how-do-i-use-dynamic-uri-in-to.html

Re: dynamic URI parameter in from URI?

Posted by Doug Douglass <do...@gmail.com>.
On Sat, Mar 9, 2013 at 1:18 AM, Claus Ibsen <cl...@gmail.com> wrote:

>
> Lets say you can do that, how you would update the option? Using some
> java code, JMX, or some other way?
>
> It is of course possible to add functionality to the camel-atom
> component so you can in some way define the uri in a dynamic way. Just
> wonder what a good solution could be?
>
> For example it could be a method call on a bean, that returns the uri to
> use.
> Or an JMX operation can be added to the consumer to change the uri at
> runtime etc.
>
> Though currently you can add new routes when you have a new need for a
> new dynamic uri. And if the old route should not longer be in service
> you can stop and remove it.
>
> If you use Java DSL then you can use a RouteBuilder as a skeleton for
> the routes. And have maybe getter/setter on it to set the uri. and
> then just
>
> MyAtomRouteBuilder builder = ....
> builder.setAtomUri(some new value here)
>
> And then in the configure method you use getAtomUri to get that uri.
>
> camelContext.addRoutes(builder);
>
>
Thanks Christian, Claus, I thought of the dynamic route option but that
seems overly complicated.

For the moment I'm using Timer and HTTP components in an integration test
just to get things working. Anonymous Processors before and after the HTTP
component are handling the dynamic parameter in the feed URL.

A little more info...the Atom feed being consumed is part of an
Atom/AtomPub service we've built for the purposes of information
integration with external systems (ala AtomServer). While it's tempting to
add a "followNext" feature/parameter to the existing Atom component, for
now this is only an example/demo of using Java/Camel as client to our
service. If we have enough external systems using Java to consume our
service, than perhaps we'll develop a custom Component that make things
simple.

Thanks again,
Doug

Re: dynamic URI parameter in from URI?

Posted by Claus Ibsen <cl...@gmail.com>.
On Fri, Mar 8, 2013 at 10:33 PM, Doug Douglass <do...@gmail.com> wrote:
> I'm familiar with dynamic to URI support in Camel[1], but I'm looking for
> ways to dynamically set the from URI or at least update a parameter in a
> from URI.
>
> Specifically, I'm using the Atom component to access a paged feed and want
> to follow "next" links to consume the entire feed (could total thousands to
> tens of thousands of entries) and then poll the feed. I'm currently using
> Camel 2.10.2, but can switch to any version if need be. Note that the Atom
> service I'm testing returns HTTP 304 if the "next" link has no updated
> entries; perhaps I should switch gears and use Timer and HTTP/HTTP4
> components and do my own processing via Abdera...
>
> Any tips are appreciated.
>

Lets say you can do that, how you would update the option? Using some
java code, JMX, or some other way?

It is of course possible to add functionality to the camel-atom
component so you can in some way define the uri in a dynamic way. Just
wonder what a good solution could be?

For example it could be a method call on a bean, that returns the uri to use.
Or an JMX operation can be added to the consumer to change the uri at
runtime etc.

Though currently you can add new routes when you have a new need for a
new dynamic uri. And if the old route should not longer be in service
you can stop and remove it.

If you use Java DSL then you can use a RouteBuilder as a skeleton for
the routes. And have maybe getter/setter on it to set the uri. and
then just

MyAtomRouteBuilder builder = ....
builder.setAtomUri(some new value here)

And then in the configure method you use getAtomUri to get that uri.

camelContext.addRoutes(builder);



> Doug
>
> [1] http://camel.apache.org/how-do-i-use-dynamic-uri-in-to.html



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: dynamic URI parameter in from URI?

Posted by Christian Müller <ch...@gmail.com>.
You have to create a new route at runtime to archive this, e.g. in a
processor:

CamelContext context = exchange.getContext();
context.addRoutes(new RouteBuilder() {
    public void configure() throws Exception {
        from("")
            .to("");
    }
});

Best,
Christian

Sent from a mobile device
Am 08.03.2013 14:34 schrieb "Doug Douglass" <do...@gmail.com>:

> I'm familiar with dynamic to URI support in Camel[1], but I'm looking for
> ways to dynamically set the from URI or at least update a parameter in a
> from URI.
>
> Specifically, I'm using the Atom component to access a paged feed and want
> to follow "next" links to consume the entire feed (could total thousands to
> tens of thousands of entries) and then poll the feed. I'm currently using
> Camel 2.10.2, but can switch to any version if need be. Note that the Atom
> service I'm testing returns HTTP 304 if the "next" link has no updated
> entries; perhaps I should switch gears and use Timer and HTTP/HTTP4
> components and do my own processing via Abdera...
>
> Any tips are appreciated.
>
> Doug
>
> [1] http://camel.apache.org/how-do-i-use-dynamic-uri-in-to.html
>