Hi Sahil,

I already replied in zulip chat, but you can start with the following
snippet:

from("direct:upload")
            .loopDoWhile(simple("${body} != '[]'"))
            .choice()
                .when(simple("${exchangeProperty.CamelLoopIndex} >
0")) // API page start from 1
                    .setHeader(Exchange.HTTP_PATH, constant("/v2/beers"))
                    .setHeader("content-type", constant("application-json"))
                    .setHeader(Exchange.HTTP_QUERY,
simple("page=${exchangeProperty.CamelLoopIndex}"))
                    .log("${headers}")
                    .toD("https://api.punkapi.com";)
                    .log("${body}")
                    //.to("s3") // UPLOAD TO S3
                .otherwise()
                    .setBody(constant(""))
                .end()
            .end();


Il giorno ven 4 ago 2023 alle ore 13:28 Sahil Upneja <upnej...@gmail.com>
ha scritto:

> Hi Ralf,
>
> Thanks for your Response.
>
> Sorry I could not understand much as I am very new to camel.
>
> Can you please share some article or code snippet (a small example) which
> is implementing something like this.
>
> That will be really a great help.
>
> Thanks in advance
>
> Regards
> Sahil
>
> On Tue, Aug 1, 2023 at 12:03 PM Claussnitzer, Ralf <
> ralf.claussnit...@slub-dresden.de> wrote:
>
> > Hi Sahil,
> >
> > as far as I know the HTTP producer does not support polling based on
> > headers. You could trigger the individual HTTP requests by using sort of
> an
> > event loop:
> >
> > Event/Message driven consumer route (direct or jms) that makes the actual
> > request and emits a follow-up event for the next page based on the
> returned
> > result (like tail recursion). Now you just need to figure out who sends
> the
> > first initial event.
> >
> > Some folks uses a timer based approach, which in my opinion has to many
> > drawbacks, because you get additional latency, difficult error handling
> and
> > have to stop polling using the control bus.
> >
> > Regards,
> > Ralf
> >
> > On Mon, 2023-07-31 at 13:09 +0530, Sahil Upneja wrote:
> >
> > Hi Everyone !
> >
> > I am trying to read data from a paginated API , Since the whole data is
> > huge so I want to read one page from paginated API and upload it as
> > multipart file to S3 and then read 2nd page & upload it to S3 and so on.
> >
> > Could you please let me know if this usecase is achievable through Camel.
> >
> > If yes, could you please also share a little example on how to achieve
> > this.
> >
> > Regards
> > Sahil
> >
> >
>

Reply via email to