You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Penagos Jaime <Ja...@ub.uni-muenchen.de> on 2023/03/02 07:03:49 UTC
ConsumerTemplate waiting indefinitely for Response
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
AW: ConsumerTemplate waiting indefinitely for Response
Posted by Penagos Jaime <Ja...@ub.uni-muenchen.de>.
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 <Ja...@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 <cl...@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.Penagos@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
Re: ConsumerTemplate waiting indefinitely for Response
Posted by Claus Ibsen <cl...@gmail.com>.
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.Penagos@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 <cl...@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.Penagos@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
AW: ConsumerTemplate waiting indefinitely for Response
Posted by Penagos Jaime <Ja...@ub.uni-muenchen.de>.
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 <cl...@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.Penagos@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
Re: ConsumerTemplate waiting indefinitely for Response
Posted by Claus Ibsen <cl...@gmail.com>.
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.Penagos@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