I solved it. I think I was trying to overkill it using a dynamic file 
component, I did read the content oft he file using Java functions and then set 
the body to the new read string. That way I think I can spare some resources on 
the camel side 😊

Thanks for all the advice! Have a great day 

-----Ursprüngliche Nachricht-----
Von: Penagos Jaime <jaime.pena...@ub.uni-muenchen.de> 
Gesendet: Donnerstag, 2. März 2023 08:59
An: users@camel.apache.org
Betreff: AW: ConsumerTemplate waiting indefinitely for Response

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

Reply via email to