You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by arshad dar <ay...@gmail.com> on 2020/06/12 08:38:44 UTC

Pause the processing of file

I have two routes below, the first route processing a very large CSV file
and the second one converts each record to JSON and forwards the message to
http-route



from(fileUri).routeId(mainRouteId).to(dataFormatURI).split(body())
 .streaming()
.to("direct:sample")

from"direct:sample"
          .marshal().json(JsonLibrary.Jackson)
          .end()
          .to("direct:http-endpoint");

is there a way I can pause the processing of a file?

I tried to suspend  the second route but the first route keeps sending
messages and I get ConsumerNotAvailableException

if I try to suspend the first route, that does not help, it just stops
polling of file component instead of pausing the current file that the
route is processing.

any help would be appreciated




-- 
Arshid

Re: Pause the processing of file

Posted by Mark Nuttall <mk...@gmail.com>.
What that means it will read and send the file line by line to the "to" -
upon successful sending to the "to" it will read and send the next line. It
fails because the direct no longer exists.

On Fri, Jun 12, 2020 at 9:48 AM arshad dar <ay...@gmail.com> wrote:

> Thank you for your response
> I was going through the documentation it says
>
> "When in streaming mode, then the splitter splits the original message
> on-demand, and each splitted
> message is processed one by one"
>
> So doesn’t that mean if we don’t have demand it won’t produce new exchanges
>
> if the route that was consuming messages from the first route is suspended.
> does not that mean that there will be no demand now and the first route
> will pause generating exchanges?
>
>
> On Fri, Jun 12, 2020 at 5:15 PM Mark Nuttall <mk...@gmail.com> wrote:
>
> > The reason the first does not work is because direct routes are just like
> > one method in a class calling another. And stopping the second is like
> > removing the method.
> >
> > What I do when processing the file is read whole file and write to a
> > topic/queue and then have the second route read from the queue. That way
> > the processing is async and i can stop the second route.
> >
> > I am doing this very thing because my second route calls a third party
> > endpoint and it could be down. If it is down, i stop the processing.
> >
> > On Fri, Jun 12, 2020 at 4:41 AM arshad dar <ay...@gmail.com> wrote:
> >
> > > I have two routes below, the first route processing a very large CSV
> file
> > > and the second one converts each record to JSON and forwards the
> message
> > to
> > > http-route
> > >
> > >
> > >
> > > from(fileUri).routeId(mainRouteId).to(dataFormatURI).split(body())
> > >  .streaming()
> > > .to("direct:sample")
> > >
> > > from"direct:sample"
> > >           .marshal().json(JsonLibrary.Jackson)
> > >           .end()
> > >           .to("direct:http-endpoint");
> > >
> > > is there a way I can pause the processing of a file?
> > >
> > > I tried to suspend  the second route but the first route keeps sending
> > > messages and I get ConsumerNotAvailableException
> > >
> > > if I try to suspend the first route, that does not help, it just stops
> > > polling of file component instead of pausing the current file that the
> > > route is processing.
> > >
> > > any help would be appreciated
> > >
> > >
> > >
> > >
> > > --
> > > Arshid
> > >
> >
>
>
> --
> Arshid
>

Re: Pause the processing of file

Posted by arshad dar <ay...@gmail.com>.
Thank you for your response
I was going through the documentation it says

"When in streaming mode, then the splitter splits the original message
on-demand, and each splitted
message is processed one by one"

So doesn’t that mean if we don’t have demand it won’t produce new exchanges

if the route that was consuming messages from the first route is suspended.
does not that mean that there will be no demand now and the first route
will pause generating exchanges?


On Fri, Jun 12, 2020 at 5:15 PM Mark Nuttall <mk...@gmail.com> wrote:

> The reason the first does not work is because direct routes are just like
> one method in a class calling another. And stopping the second is like
> removing the method.
>
> What I do when processing the file is read whole file and write to a
> topic/queue and then have the second route read from the queue. That way
> the processing is async and i can stop the second route.
>
> I am doing this very thing because my second route calls a third party
> endpoint and it could be down. If it is down, i stop the processing.
>
> On Fri, Jun 12, 2020 at 4:41 AM arshad dar <ay...@gmail.com> wrote:
>
> > I have two routes below, the first route processing a very large CSV file
> > and the second one converts each record to JSON and forwards the message
> to
> > http-route
> >
> >
> >
> > from(fileUri).routeId(mainRouteId).to(dataFormatURI).split(body())
> >  .streaming()
> > .to("direct:sample")
> >
> > from"direct:sample"
> >           .marshal().json(JsonLibrary.Jackson)
> >           .end()
> >           .to("direct:http-endpoint");
> >
> > is there a way I can pause the processing of a file?
> >
> > I tried to suspend  the second route but the first route keeps sending
> > messages and I get ConsumerNotAvailableException
> >
> > if I try to suspend the first route, that does not help, it just stops
> > polling of file component instead of pausing the current file that the
> > route is processing.
> >
> > any help would be appreciated
> >
> >
> >
> >
> > --
> > Arshid
> >
>


-- 
Arshid

Re: Pause the processing of file

Posted by Mark Nuttall <mk...@gmail.com>.
The reason the first does not work is because direct routes are just like
one method in a class calling another. And stopping the second is like
removing the method.

What I do when processing the file is read whole file and write to a
topic/queue and then have the second route read from the queue. That way
the processing is async and i can stop the second route.

I am doing this very thing because my second route calls a third party
endpoint and it could be down. If it is down, i stop the processing.

On Fri, Jun 12, 2020 at 4:41 AM arshad dar <ay...@gmail.com> wrote:

> I have two routes below, the first route processing a very large CSV file
> and the second one converts each record to JSON and forwards the message to
> http-route
>
>
>
> from(fileUri).routeId(mainRouteId).to(dataFormatURI).split(body())
>  .streaming()
> .to("direct:sample")
>
> from"direct:sample"
>           .marshal().json(JsonLibrary.Jackson)
>           .end()
>           .to("direct:http-endpoint");
>
> is there a way I can pause the processing of a file?
>
> I tried to suspend  the second route but the first route keeps sending
> messages and I get ConsumerNotAvailableException
>
> if I try to suspend the first route, that does not help, it just stops
> polling of file component instead of pausing the current file that the
> route is processing.
>
> any help would be appreciated
>
>
>
>
> --
> Arshid
>