Hi

To read a file you can just return a java.io.File object pointing to the
file, or a FileInputStream etc from the processor.

On Thu, Mar 2, 2023 at 8:59 AM Penagos Jaime <
jaime.pena...@ub.uni-muenchen.de> wrote:

> Hello,
>
> I tried using that one, but it would not return the body of the file, just
> an empty string. Maybe creating an Endpoint could help? I will try to test
> if it loads the information I need.
>
> *fingers crossed*
>
> -----Ursprüngliche Nachricht-----
> Von: Claus Ibsen <claus.ib...@gmail.com>
> Gesendet: Donnerstag, 2. März 2023 08:47
> An: users@camel.apache.org
> Betreff: Re: ConsumerTemplate waiting indefinitely for Response
>
> Hi
>
> See the options about using a timeout value to not wait for a long time
> https://camel.apache.org/manual/consumertemplate.html#_receive_modes
>
>
>
> On Thu, Mar 2, 2023 at 8:04 AM Penagos Jaime <
> jaime.pena...@ub.uni-muenchen.de> wrote:
>
> > Hello everyone,
> >
> > I am working right now with some REST Routes in Camel, and one of
> > those routes is supposed to read a file on a specific folder and
> > return the result. The name of the file is given on the URI (i.e. GET
> /file/{name}).
> > It seems to work fine, although when I send the same request to that
> > route, it won't return anything and just keeps waiting for response.
> >
> > Internally the route looks something like this:
> >
> >
> > rest("/")
> >      .get("/file/{name}").to("direct:getContent");
> >
> > from("direct:getContent")
> >     .tracing()
> >     .process(getContentProcessor)
> >     .setHeader(Exchange.CONTENT_TYPE, constant("application/json"))
> >     .transform(body());
> >
> >
> >
> > and within the processor I use a ConsumerTemplate to load the file:
> >
> > ...
> >
> > ConsumerTemplate myConsumer =
> > exchange.getContext().createConsumerTemplate();
> > String fileResult = (String) myConsumer.receiveBody(
> >           "file:data?fileName=" + myFileToCheck + "&noop=true",
> > String.class
> >      );
> >
> > ...
> >
> > I *suppose* that when the consumer calls the endpoint, it gets the
> > same id and Camel won't continue? What could be the issue here? I
> > double checked (and also used the noop parameter to be certain the
> > file stays in the same
> > folder)
> >
> > Thanks for your advice,
> >
> > Best regards,
> > Jaime Penagos
> >
>
>
> --
> Claus Ibsen
> -----------------
> @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
>


-- 
Claus Ibsen
-----------------
@davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Reply via email to