RE: Issue with ProducerTemplate (processor not started)
Hi Claus Oh, yes, that makes everything more easy! Thank you so much for your super quick response and your great help!!! By the way: I love Camel (not the cigarette). Thanks for that great product! Reto -Original Message- From: Claus Ibsen Sent: Friday, 11 August 2023 23:13 To: users@camel.apache.org Subject: Re: Issue with ProducerTemplate (processor not started) On Fri, Aug 11, 2023 at 5:08 PM Reto Peter wrote: > Hi Claus > > You mean I should just change my executeQuery route this way, from > dynamic to static? > > OLD > from("direct:executeQuery") > .toD("sql:${header.sqlquery}") > > NEW > from("direct:executeQuery") > .setHeader("CamelSqlQuery", simple("${header.sqlquery}" > .to("sql:SELECT") > > Correct? > But the bean class does still have the injected producerTemplate. The > only change is the static call to the sql component > > Yes correct and you can also just set the header from the template and avoid the .setHeader in the route result = producer.requestBodyAndHeader("direct:executeQuery", "", "CamelSqlQuery", query); And since you route is just from direct to sql, you can also call it directly from template, and not have that route result = producer.requestBodyAndHeader("sql:SELECT", "", "CamelSqlQuery", query); > -Original Message- > From: Claus Ibsen > Sent: Friday, 11 August 2023 22:54 > To: users@camel.apache.org > Subject: Re: Issue with ProducerTemplate (processor not started) > > Hi > > Its much better to use a header with the dynamic query (key = > SqlConstants.SQL_QUERY) > https://camel.apache.org/components/3.21.x/sql-component.html#_message > _headers > > and use a static "to" endpoint then you dont have the overhead of > creating a new endpoint/producer per SQL query combination. > > > > > On Fri, Aug 11, 2023 at 4:39 PM Reto Peter > wrote: > > > Hi Claus > > > > Thanks for fast response. > > The call is to an SQL query: > > result = producer.requestBodyAndHeader("direct:executeQuery", "", > > "sqlquery", query); > > > > and the route looks like this: > > from("direct:executeQuery") > > .routeId("Execute resolvement query") > > .toD("sql:${header.sqlquery}") > > ; > > > > -Original Message- > > From: Claus Ibsen > > Sent: Friday, 11 August 2023 22:29 > > To: users@camel.apache.org > > Subject: Re: Issue with ProducerTemplate (processor not started) > > > > What endpoint do you send to with the producer template > > > > On Fri, Aug 11, 2023 at 4:15 PM Reto Peter > > wrote: > > > > > Hi > > > > > > I got an issue with the ProducerTemplate used inside a bean The > > > Bean class called Resolvement.class injects the ProducerTemplate > > > as > > > follows: > > > > > > > > > @EndpointInject > > > > > > private ProducerTemplate producer; > > > > > > inside the bean resolve() method, I do then use this producer like > this: > > > > > > producer.requestBodyAndHeader(...) > > > > > > The method of the bean class is called by a camel route as follows: > > > > > > .split(simple("${body}"), new CSVFileAggregator()) > > > > > > .parallelProcessing() > > > > > > .bean(Resolvement.class, "resolve") > > > > > > That normally works fine! > > > But in some cases, I get an error like this: > > > Caused by: java.lang.IllegalStateException: No producer, this > > > processor has not been started: ProducerCache for source: toD20, > > capacity: 1000 > > > at > > > > > org.apache.camel.support.cache.DefaultProducerCache.doInAsyncProduce > > r( > > DefaultProducerCache.java:300) > > > at > > > > > org.apache.camel.processor.SendDynamicProcessor.process(SendDynamicP > > ro > > cessor.java:182) > > > at > > > > > org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$Simpl > > eT > > ask.run(RedeliveryErrorHandler.java:477) > > > at > > > > > org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.executeF > > ro > > mQueue(DefaultReactiveExecutor.java:212) > > > at > > > > > org.apache.camel.impl.engine.DefaultReactiveExecutor.executeFromQu
Re: Issue with ProducerTemplate (processor not started)
On Fri, Aug 11, 2023 at 5:08 PM Reto Peter wrote: > Hi Claus > > You mean I should just change my executeQuery route this way, from dynamic > to static? > > OLD > from("direct:executeQuery") > .toD("sql:${header.sqlquery}") > > NEW > from("direct:executeQuery") > .setHeader("CamelSqlQuery", simple("${header.sqlquery}" > .to("sql:SELECT") > > Correct? > But the bean class does still have the injected producerTemplate. The only > change is the static call to the sql component > > Yes correct and you can also just set the header from the template and avoid the .setHeader in the route result = producer.requestBodyAndHeader("direct:executeQuery", "", "CamelSqlQuery", query); And since you route is just from direct to sql, you can also call it directly from template, and not have that route result = producer.requestBodyAndHeader("sql:SELECT", "", "CamelSqlQuery", query); > -Original Message- > From: Claus Ibsen > Sent: Friday, 11 August 2023 22:54 > To: users@camel.apache.org > Subject: Re: Issue with ProducerTemplate (processor not started) > > Hi > > Its much better to use a header with the dynamic query (key = > SqlConstants.SQL_QUERY) > https://camel.apache.org/components/3.21.x/sql-component.html#_message_headers > > and use a static "to" endpoint then you dont have the overhead of creating > a new endpoint/producer per SQL query combination. > > > > > On Fri, Aug 11, 2023 at 4:39 PM Reto Peter > wrote: > > > Hi Claus > > > > Thanks for fast response. > > The call is to an SQL query: > > result = producer.requestBodyAndHeader("direct:executeQuery", "", > > "sqlquery", query); > > > > and the route looks like this: > > from("direct:executeQuery") > > .routeId("Execute resolvement query") > > .toD("sql:${header.sqlquery}") > > ; > > > > -Original Message- > > From: Claus Ibsen > > Sent: Friday, 11 August 2023 22:29 > > To: users@camel.apache.org > > Subject: Re: Issue with ProducerTemplate (processor not started) > > > > What endpoint do you send to with the producer template > > > > On Fri, Aug 11, 2023 at 4:15 PM Reto Peter > > wrote: > > > > > Hi > > > > > > I got an issue with the ProducerTemplate used inside a bean The Bean > > > class called Resolvement.class injects the ProducerTemplate as > > > follows: > > > > > > > > > @EndpointInject > > > > > > private ProducerTemplate producer; > > > > > > inside the bean resolve() method, I do then use this producer like > this: > > > > > > producer.requestBodyAndHeader(...) > > > > > > The method of the bean class is called by a camel route as follows: > > > > > > .split(simple("${body}"), new CSVFileAggregator()) > > > > > > .parallelProcessing() > > > > > > .bean(Resolvement.class, "resolve") > > > > > > That normally works fine! > > > But in some cases, I get an error like this: > > > Caused by: java.lang.IllegalStateException: No producer, this > > > processor has not been started: ProducerCache for source: toD20, > > capacity: 1000 > > > at > > > > > org.apache.camel.support.cache.DefaultProducerCache.doInAsyncProducer( > > DefaultProducerCache.java:300) > > > at > > > > > org.apache.camel.processor.SendDynamicProcessor.process(SendDynamicPro > > cessor.java:182) > > > at > > > > > org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$SimpleT > > ask.run(RedeliveryErrorHandler.java:477) > > > at > > > > > org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.executeFro > > mQueue(DefaultReactiveExecutor.java:212) > > > at > > > > > org.apache.camel.impl.engine.DefaultReactiveExecutor.executeFromQueue( > > DefaultReactiveExecutor.java:77) > > > at > > > > > org.apache.camel.impl.engine.DefaultAsyncProcessorAwaitManager.await(D > > efaultAsyncProcessorAwaitManager.java:96) > > > at > > > > > org.apache.camel.impl.engine.DefaultAsyncProcessorAwaitManager.process > > (DefaultAsyncProcessorAwaitManager.java:85) > > > at > > > > > org.apache.camel.impl.engine.Shared
RE: Issue with ProducerTemplate (processor not started)
Hi Claus You mean I should just change my executeQuery route this way, from dynamic to static? OLD from("direct:executeQuery") .toD("sql:${header.sqlquery}") NEW from("direct:executeQuery") .setHeader("CamelSqlQuery", simple("${header.sqlquery}" .to("sql:SELECT") Correct? But the bean class does still have the injected producerTemplate. The only change is the static call to the sql component -Original Message- From: Claus Ibsen Sent: Friday, 11 August 2023 22:54 To: users@camel.apache.org Subject: Re: Issue with ProducerTemplate (processor not started) Hi Its much better to use a header with the dynamic query (key = SqlConstants.SQL_QUERY) https://camel.apache.org/components/3.21.x/sql-component.html#_message_headers and use a static "to" endpoint then you dont have the overhead of creating a new endpoint/producer per SQL query combination. On Fri, Aug 11, 2023 at 4:39 PM Reto Peter wrote: > Hi Claus > > Thanks for fast response. > The call is to an SQL query: > result = producer.requestBodyAndHeader("direct:executeQuery", "", > "sqlquery", query); > > and the route looks like this: > from("direct:executeQuery") > .routeId("Execute resolvement query") > .toD("sql:${header.sqlquery}") > ; > > -Original Message- > From: Claus Ibsen > Sent: Friday, 11 August 2023 22:29 > To: users@camel.apache.org > Subject: Re: Issue with ProducerTemplate (processor not started) > > What endpoint do you send to with the producer template > > On Fri, Aug 11, 2023 at 4:15 PM Reto Peter > wrote: > > > Hi > > > > I got an issue with the ProducerTemplate used inside a bean The Bean > > class called Resolvement.class injects the ProducerTemplate as > > follows: > > > > > > @EndpointInject > > > > private ProducerTemplate producer; > > > > inside the bean resolve() method, I do then use this producer like this: > > > > producer.requestBodyAndHeader(...) > > > > The method of the bean class is called by a camel route as follows: > > > > .split(simple("${body}"), new CSVFileAggregator()) > > > > .parallelProcessing() > > > > .bean(Resolvement.class, "resolve") > > > > That normally works fine! > > But in some cases, I get an error like this: > > Caused by: java.lang.IllegalStateException: No producer, this > > processor has not been started: ProducerCache for source: toD20, > capacity: 1000 > > at > > > org.apache.camel.support.cache.DefaultProducerCache.doInAsyncProducer( > DefaultProducerCache.java:300) > > at > > > org.apache.camel.processor.SendDynamicProcessor.process(SendDynamicPro > cessor.java:182) > > at > > > org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$SimpleT > ask.run(RedeliveryErrorHandler.java:477) > > at > > > org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.executeFro > mQueue(DefaultReactiveExecutor.java:212) > > at > > > org.apache.camel.impl.engine.DefaultReactiveExecutor.executeFromQueue( > DefaultReactiveExecutor.java:77) > > at > > > org.apache.camel.impl.engine.DefaultAsyncProcessorAwaitManager.await(D > efaultAsyncProcessorAwaitManager.java:96) > > at > > > org.apache.camel.impl.engine.DefaultAsyncProcessorAwaitManager.process > (DefaultAsyncProcessorAwaitManager.java:85) > > at > > > org.apache.camel.impl.engine.SharedCamelInternalProcessor.process(Shar > edCamelInternalProcessor.java:108) > > at > > > org.apache.camel.support.cache.DefaultProducerCache.send(DefaultProduc > erCache.java:199) > > at > > > org.apache.camel.impl.engine.DefaultProducerTemplate.send(DefaultProdu > cerTemplate.java:176) > > at > > > org.apache.camel.impl.engine.DefaultProducerTemplate.send(DefaultProdu > cerTemplate.java:172) > > at > > > org.apache.camel.impl.engine.DefaultProducerTemplate.send(DefaultProdu > cerTemplate.java:158) > > at > > org.apache.camel.impl.engine.DefaultProducerTemplate.sendBodyAndHead > > er > > (DefaultProducerTemplate.java:229) > > > > That means for me, in some situations the Producer is not properly > > initialized. > > > > My question is: > > How can I make sure the producer is initialized properly? > > Is this a synchronization issue cause I do use parallelProcessing > > and I must use some synchronizing strategies? > > Or what could be the problem or the method to help for this issue? > > > > Camel Version: 3.20.6 > > Java: 17 > > Sping Boot 2.7.12 > > > > > -- > Claus Ibsen > - > @davsclaus > Camel in Action 2: https://www.manning.com/ibsen2 > -- Claus Ibsen - @davsclaus Camel in Action 2: https://www.manning.com/ibsen2
Re: Issue with ProducerTemplate (processor not started)
Hi Its much better to use a header with the dynamic query (key = SqlConstants.SQL_QUERY) https://camel.apache.org/components/3.21.x/sql-component.html#_message_headers and use a static "to" endpoint then you dont have the overhead of creating a new endpoint/producer per SQL query combination. On Fri, Aug 11, 2023 at 4:39 PM Reto Peter wrote: > Hi Claus > > Thanks for fast response. > The call is to an SQL query: > result = producer.requestBodyAndHeader("direct:executeQuery", "", > "sqlquery", query); > > and the route looks like this: > from("direct:executeQuery") > .routeId("Execute resolvement query") > .toD("sql:${header.sqlquery}") > ; > > -Original Message- > From: Claus Ibsen > Sent: Friday, 11 August 2023 22:29 > To: users@camel.apache.org > Subject: Re: Issue with ProducerTemplate (processor not started) > > What endpoint do you send to with the producer template > > On Fri, Aug 11, 2023 at 4:15 PM Reto Peter > wrote: > > > Hi > > > > I got an issue with the ProducerTemplate used inside a bean The Bean > > class called Resolvement.class injects the ProducerTemplate as > > follows: > > > > > > @EndpointInject > > > > private ProducerTemplate producer; > > > > inside the bean resolve() method, I do then use this producer like this: > > > > producer.requestBodyAndHeader(...) > > > > The method of the bean class is called by a camel route as follows: > > > > .split(simple("${body}"), new CSVFileAggregator()) > > > > .parallelProcessing() > > > > .bean(Resolvement.class, "resolve") > > > > That normally works fine! > > But in some cases, I get an error like this: > > Caused by: java.lang.IllegalStateException: No producer, this > > processor has not been started: ProducerCache for source: toD20, > capacity: 1000 > > at > > > org.apache.camel.support.cache.DefaultProducerCache.doInAsyncProducer(DefaultProducerCache.java:300) > > at > > > org.apache.camel.processor.SendDynamicProcessor.process(SendDynamicProcessor.java:182) > > at > > > org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$SimpleTask.run(RedeliveryErrorHandler.java:477) > > at > > > org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.executeFromQueue(DefaultReactiveExecutor.java:212) > > at > > > org.apache.camel.impl.engine.DefaultReactiveExecutor.executeFromQueue(DefaultReactiveExecutor.java:77) > > at > > > org.apache.camel.impl.engine.DefaultAsyncProcessorAwaitManager.await(DefaultAsyncProcessorAwaitManager.java:96) > > at > > > org.apache.camel.impl.engine.DefaultAsyncProcessorAwaitManager.process(DefaultAsyncProcessorAwaitManager.java:85) > > at > > > org.apache.camel.impl.engine.SharedCamelInternalProcessor.process(SharedCamelInternalProcessor.java:108) > > at > > > org.apache.camel.support.cache.DefaultProducerCache.send(DefaultProducerCache.java:199) > > at > > > org.apache.camel.impl.engine.DefaultProducerTemplate.send(DefaultProducerTemplate.java:176) > > at > > > org.apache.camel.impl.engine.DefaultProducerTemplate.send(DefaultProducerTemplate.java:172) > > at > > > org.apache.camel.impl.engine.DefaultProducerTemplate.send(DefaultProducerTemplate.java:158) > > at > > org.apache.camel.impl.engine.DefaultProducerTemplate.sendBodyAndHeader > > (DefaultProducerTemplate.java:229) > > > > That means for me, in some situations the Producer is not properly > > initialized. > > > > My question is: > > How can I make sure the producer is initialized properly? > > Is this a synchronization issue cause I do use parallelProcessing and > > I must use some synchronizing strategies? > > Or what could be the problem or the method to help for this issue? > > > > Camel Version: 3.20.6 > > Java: 17 > > Sping Boot 2.7.12 > > > > > -- > Claus Ibsen > - > @davsclaus > Camel in Action 2: https://www.manning.com/ibsen2 > -- Claus Ibsen - @davsclaus Camel in Action 2: https://www.manning.com/ibsen2
RE: Issue with ProducerTemplate (processor not started)
Hi Claus Thanks for fast response. The call is to an SQL query: result = producer.requestBodyAndHeader("direct:executeQuery", "", "sqlquery", query); and the route looks like this: from("direct:executeQuery") .routeId("Execute resolvement query") .toD("sql:${header.sqlquery}") ; -Original Message- From: Claus Ibsen Sent: Friday, 11 August 2023 22:29 To: users@camel.apache.org Subject: Re: Issue with ProducerTemplate (processor not started) What endpoint do you send to with the producer template On Fri, Aug 11, 2023 at 4:15 PM Reto Peter wrote: > Hi > > I got an issue with the ProducerTemplate used inside a bean The Bean > class called Resolvement.class injects the ProducerTemplate as > follows: > > > @EndpointInject > > private ProducerTemplate producer; > > inside the bean resolve() method, I do then use this producer like this: > > producer.requestBodyAndHeader(...) > > The method of the bean class is called by a camel route as follows: > > .split(simple("${body}"), new CSVFileAggregator()) > > .parallelProcessing() > > .bean(Resolvement.class, "resolve") > > That normally works fine! > But in some cases, I get an error like this: > Caused by: java.lang.IllegalStateException: No producer, this > processor has not been started: ProducerCache for source: toD20, capacity: > 1000 > at > org.apache.camel.support.cache.DefaultProducerCache.doInAsyncProducer(DefaultProducerCache.java:300) > at > org.apache.camel.processor.SendDynamicProcessor.process(SendDynamicProcessor.java:182) > at > org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$SimpleTask.run(RedeliveryErrorHandler.java:477) > at > org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.executeFromQueue(DefaultReactiveExecutor.java:212) > at > org.apache.camel.impl.engine.DefaultReactiveExecutor.executeFromQueue(DefaultReactiveExecutor.java:77) > at > org.apache.camel.impl.engine.DefaultAsyncProcessorAwaitManager.await(DefaultAsyncProcessorAwaitManager.java:96) > at > org.apache.camel.impl.engine.DefaultAsyncProcessorAwaitManager.process(DefaultAsyncProcessorAwaitManager.java:85) > at > org.apache.camel.impl.engine.SharedCamelInternalProcessor.process(SharedCamelInternalProcessor.java:108) > at > org.apache.camel.support.cache.DefaultProducerCache.send(DefaultProducerCache.java:199) > at > org.apache.camel.impl.engine.DefaultProducerTemplate.send(DefaultProducerTemplate.java:176) > at > org.apache.camel.impl.engine.DefaultProducerTemplate.send(DefaultProducerTemplate.java:172) > at > org.apache.camel.impl.engine.DefaultProducerTemplate.send(DefaultProducerTemplate.java:158) > at > org.apache.camel.impl.engine.DefaultProducerTemplate.sendBodyAndHeader > (DefaultProducerTemplate.java:229) > > That means for me, in some situations the Producer is not properly > initialized. > > My question is: > How can I make sure the producer is initialized properly? > Is this a synchronization issue cause I do use parallelProcessing and > I must use some synchronizing strategies? > Or what could be the problem or the method to help for this issue? > > Camel Version: 3.20.6 > Java: 17 > Sping Boot 2.7.12 > -- Claus Ibsen - @davsclaus Camel in Action 2: https://www.manning.com/ibsen2
Re: Issue with ProducerTemplate (processor not started)
What endpoint do you send to with the producer template On Fri, Aug 11, 2023 at 4:15 PM Reto Peter wrote: > Hi > > I got an issue with the ProducerTemplate used inside a bean > The Bean class called Resolvement.class injects the ProducerTemplate as > follows: > > > @EndpointInject > > private ProducerTemplate producer; > > inside the bean resolve() method, I do then use this producer like this: > > producer.requestBodyAndHeader(...) > > The method of the bean class is called by a camel route as follows: > > .split(simple("${body}"), new CSVFileAggregator()) > > .parallelProcessing() > > .bean(Resolvement.class, "resolve") > > That normally works fine! > But in some cases, I get an error like this: > Caused by: java.lang.IllegalStateException: No producer, this processor > has not been started: ProducerCache for source: toD20, capacity: 1000 > at > org.apache.camel.support.cache.DefaultProducerCache.doInAsyncProducer(DefaultProducerCache.java:300) > at > org.apache.camel.processor.SendDynamicProcessor.process(SendDynamicProcessor.java:182) > at > org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$SimpleTask.run(RedeliveryErrorHandler.java:477) > at > org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.executeFromQueue(DefaultReactiveExecutor.java:212) > at > org.apache.camel.impl.engine.DefaultReactiveExecutor.executeFromQueue(DefaultReactiveExecutor.java:77) > at > org.apache.camel.impl.engine.DefaultAsyncProcessorAwaitManager.await(DefaultAsyncProcessorAwaitManager.java:96) > at > org.apache.camel.impl.engine.DefaultAsyncProcessorAwaitManager.process(DefaultAsyncProcessorAwaitManager.java:85) > at > org.apache.camel.impl.engine.SharedCamelInternalProcessor.process(SharedCamelInternalProcessor.java:108) > at > org.apache.camel.support.cache.DefaultProducerCache.send(DefaultProducerCache.java:199) > at > org.apache.camel.impl.engine.DefaultProducerTemplate.send(DefaultProducerTemplate.java:176) > at > org.apache.camel.impl.engine.DefaultProducerTemplate.send(DefaultProducerTemplate.java:172) > at > org.apache.camel.impl.engine.DefaultProducerTemplate.send(DefaultProducerTemplate.java:158) > at > org.apache.camel.impl.engine.DefaultProducerTemplate.sendBodyAndHeader(DefaultProducerTemplate.java:229) > > That means for me, in some situations the Producer is not properly > initialized. > > My question is: > How can I make sure the producer is initialized properly? > Is this a synchronization issue cause I do use parallelProcessing and I > must use some synchronizing strategies? > Or what could be the problem or the method to help for this issue? > > Camel Version: 3.20.6 > Java: 17 > Sping Boot 2.7.12 > -- Claus Ibsen - @davsclaus Camel in Action 2: https://www.manning.com/ibsen2
Issue with ProducerTemplate (processor not started)
Hi I got an issue with the ProducerTemplate used inside a bean The Bean class called Resolvement.class injects the ProducerTemplate as follows: @EndpointInject private ProducerTemplate producer; inside the bean resolve() method, I do then use this producer like this: producer.requestBodyAndHeader(...) The method of the bean class is called by a camel route as follows: .split(simple("${body}"), new CSVFileAggregator()) .parallelProcessing() .bean(Resolvement.class, "resolve") That normally works fine! But in some cases, I get an error like this: Caused by: java.lang.IllegalStateException: No producer, this processor has not been started: ProducerCache for source: toD20, capacity: 1000 at org.apache.camel.support.cache.DefaultProducerCache.doInAsyncProducer(DefaultProducerCache.java:300) at org.apache.camel.processor.SendDynamicProcessor.process(SendDynamicProcessor.java:182) at org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$SimpleTask.run(RedeliveryErrorHandler.java:477) at org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.executeFromQueue(DefaultReactiveExecutor.java:212) at org.apache.camel.impl.engine.DefaultReactiveExecutor.executeFromQueue(DefaultReactiveExecutor.java:77) at org.apache.camel.impl.engine.DefaultAsyncProcessorAwaitManager.await(DefaultAsyncProcessorAwaitManager.java:96) at org.apache.camel.impl.engine.DefaultAsyncProcessorAwaitManager.process(DefaultAsyncProcessorAwaitManager.java:85) at org.apache.camel.impl.engine.SharedCamelInternalProcessor.process(SharedCamelInternalProcessor.java:108) at org.apache.camel.support.cache.DefaultProducerCache.send(DefaultProducerCache.java:199) at org.apache.camel.impl.engine.DefaultProducerTemplate.send(DefaultProducerTemplate.java:176) at org.apache.camel.impl.engine.DefaultProducerTemplate.send(DefaultProducerTemplate.java:172) at org.apache.camel.impl.engine.DefaultProducerTemplate.send(DefaultProducerTemplate.java:158) at org.apache.camel.impl.engine.DefaultProducerTemplate.sendBodyAndHeader(DefaultProducerTemplate.java:229) That means for me, in some situations the Producer is not properly initialized. My question is: How can I make sure the producer is initialized properly? Is this a synchronization issue cause I do use parallelProcessing and I must use some synchronizing strategies? Or what could be the problem or the method to help for this issue? Camel Version: 3.20.6 Java: 17 Sping Boot 2.7.12
RE: ProducerTemplate is waiting on something
Btw, just realized there are 3 different timeouts available on Camel HTTP component (!) https://camel.apache.org/components/3.20.x/http-component.html#_using_client_timeout_so_timeout, will go with that. From: Shultz, Dmitry Sent: Thursday, May 4, 2023 11:38 AM To: users@camel.apache.org Subject: RE: ProducerTemplate is waiting on something Thanks Claus! There is DefaultAsyncProcessAwaitManager and it has getThreadsBlocked() operation, but it returns 0. There is also DegfaultInflightRepository with browse() operation, but I can’t get anything because InflightBrowseEnabled (this ZjQcmQRYFpfptBannerStart This Message Is From an External Sender ZjQcmQRYFpfptBannerEnd Thanks Claus! There is DefaultAsyncProcessAwaitManager and it has getThreadsBlocked() operation, but it returns 0. There is also DegfaultInflightRepository with browse() operation, but I can’t get anything because InflightBrowseEnabled (this is required to be enabled for the browse operations to function.) is false and not writable… Anyway, I can see the problem now and have a question about how to solve it. The root cause is that our service is sending request to some third party service which apparently is not behaving sometimes… The easiest way would be to use ProducerTemplate async call instead of sync one because in this case we don’t care about response (the call just triggers some processing). I’m wondering if there is any default timeout on ProducerTemplate.asyncSendBody() or what is proper way to achieve the timeout behaviour (is this good enough https://urldefense.com/v3/__https://stackoverflow.com/questions/49308074/apache-camel-timeout-synchronous-route__;!!LdWlNaMnLCM!bvM0mbo74CfXYJr-jbebQ6s7ZXjvJ9FSNlNn785EagnirMSYSFtewGl-w9oSOQeuYyqK5-nJSazUoPgaPtiFcUgpeROHTA$<https://urldefense.com/v3/__https:/stackoverflow.com/questions/49308074/apache-camel-timeout-synchronous-route__;!!LdWlNaMnLCM!bvM0mbo74CfXYJr-jbebQ6s7ZXjvJ9FSNlNn785EagnirMSYSFtewGl-w9oSOQeuYyqK5-nJSazUoPgaPtiFcUgpeROHTA$> ?). Btw, what will happen if we do nothing and these calls got stuck during Camel async processing? From: Claus Ibsen mailto:claus.ib...@gmail.com>> Sent: Thursday, May 4, 2023 11:09 AM To: users@camel.apache.org<mailto:users@camel.apache.org> Subject: Re: ProducerTemplate is waiting on something Hi There is a mbean under services (I think) that has something with await manager - it has operations to list the blocked On Thu, May 4, 2023 at 8: 01 PM Shultz, Dmitry wrote: > Thanks Claus, it helped a ZjQcmQRYFpfptBannerStart This Message Is From an External Sender ZjQcmQRYFpfptBannerEnd Hi There is a mbean under services (I think) that has something with await manager - it has operations to list the blocked On Thu, May 4, 2023 at 8:01 PM Shultz, Dmitry mailto:dmitry_shu...@kaltire.com<mailto:dmitry_shu...@kaltire.com%3cmailto:dmitry_shu...@kaltire.com>>> wrote: > Thanks Claus, it helped a lot! > > I can see the ‘Exchanges Inflight’ number in the jconsole > org.apache.camel->routes->route-id->Attributes->Exchanges Inflight, but you > mentioned there is some way to see the list of actual exchanges. > What is the path in jconsole to see it? > > Dmitry > > > > From: Claus Ibsen > mailto:claus.ib...@gmail.com<mailto:claus.ib...@gmail.com%3cmailto:claus.ib...@gmail.com>>> > Sent: Thursday, May 4, 2023 4:05 AM > To: > users@camel.apache.org<mailto:users@camel.apache.org<mailto:users@camel.apache.org%3cmailto:users@camel.apache.org>> > Subject: Re: ProducerTemplate is waiting on something > > Hi That indicates that a camel component is waiting for a reply that is > taking a very long time, or not happening, or a timeout is not being > triggered. You can use JMX and look in blocked exchanges to see a list and > where they are in the route, > ZjQcmQRYFpfptBannerStart > This Message Is From an External Sender > ZjQcmQRYFpfptBannerEnd > > Hi > > > > That indicates that a camel component is waiting for a reply that is taking > > a very long time, > > or not happening, or a timeout is not being triggered. > > > > You can use JMX and look in blocked exchanges to see a list and where they > > are in the route, and unblock them also. > > hawtio also have a page to show that. > > > > Also if you are using CXF then you can use it in synchronous=true mode as > > its async mode may cause this situation (it did that in the past) > > > > On Thu, May 4, 2023 at 12:44 AM Shultz, Dmitry <mailto:dmitry_shu...@kaltire.com>> > > wrote: > > > > > Hi All, > > >
RE: ProducerTemplate is waiting on something
Thanks Claus! There is DefaultAsyncProcessAwaitManager and it has getThreadsBlocked() operation, but it returns 0. There is also DegfaultInflightRepository with browse() operation, but I can’t get anything because InflightBrowseEnabled (this is required to be enabled for the browse operations to function.) is false and not writable… Anyway, I can see the problem now and have a question about how to solve it. The root cause is that our service is sending request to some third party service which apparently is not behaving sometimes… The easiest way would be to use ProducerTemplate async call instead of sync one because in this case we don’t care about response (the call just triggers some processing). I’m wondering if there is any default timeout on ProducerTemplate.asyncSendBody() or what is proper way to achieve the timeout behaviour (is this good enough https://stackoverflow.com/questions/49308074/apache-camel-timeout-synchronous-route ?). Btw, what will happen if we do nothing and these calls got stuck during Camel async processing? From: Claus Ibsen Sent: Thursday, May 4, 2023 11:09 AM To: users@camel.apache.org Subject: Re: ProducerTemplate is waiting on something Hi There is a mbean under services (I think) that has something with await manager - it has operations to list the blocked On Thu, May 4, 2023 at 8: 01 PM Shultz, Dmitry wrote: > Thanks Claus, it helped a ZjQcmQRYFpfptBannerStart This Message Is From an External Sender ZjQcmQRYFpfptBannerEnd Hi There is a mbean under services (I think) that has something with await manager - it has operations to list the blocked On Thu, May 4, 2023 at 8:01 PM Shultz, Dmitry mailto:dmitry_shu...@kaltire.com>> wrote: > Thanks Claus, it helped a lot! > > I can see the ‘Exchanges Inflight’ number in the jconsole > org.apache.camel->routes->route-id->Attributes->Exchanges Inflight, but you > mentioned there is some way to see the list of actual exchanges. > What is the path in jconsole to see it? > > Dmitry > > > > From: Claus Ibsen mailto:claus.ib...@gmail.com>> > Sent: Thursday, May 4, 2023 4:05 AM > To: users@camel.apache.org<mailto:users@camel.apache.org> > Subject: Re: ProducerTemplate is waiting on something > > Hi That indicates that a camel component is waiting for a reply that is > taking a very long time, or not happening, or a timeout is not being > triggered. You can use JMX and look in blocked exchanges to see a list and > where they are in the route, > ZjQcmQRYFpfptBannerStart > This Message Is From an External Sender > ZjQcmQRYFpfptBannerEnd > > Hi > > > > That indicates that a camel component is waiting for a reply that is taking > > a very long time, > > or not happening, or a timeout is not being triggered. > > > > You can use JMX and look in blocked exchanges to see a list and where they > > are in the route, and unblock them also. > > hawtio also have a page to show that. > > > > Also if you are using CXF then you can use it in synchronous=true mode as > > its async mode may cause this situation (it did that in the past) > > > > On Thu, May 4, 2023 at 12:44 AM Shultz, Dmitry <mailto:dmitry_shu...@kaltire.com>> > > wrote: > > > > > Hi All, > > > > > > We are having occasional problems with the some app using Camel 3.14.1 > > > rest routes and running in TomEE. After a while TomEE/Tomcat https > > > interface became unresponsive. > > > Looking at the thread dump I can see a lot of threads in such state: > > > > > > "https-jsse-nio-7443-exec-107" - Thread t@504 > > >java.lang.Thread.State: WAITING > > > at sun.misc.Unsafe.park(Native Method) > > > - parking to wait for <78a7fac3> (a > > > java.util.concurrent.CountDownLatch$Sync) > > > at > > > java.util.concurrent.locks.LockSupport.park(LockSupport.java:175) > > > at > > > > java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:836) > > > at > > > > java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:997) > > > at > > > > java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1304) > > > at > > > java.util.concurrent.CountDownLatch.await(CountDownLatch.java:231) > > > at > > > > org.apache.camel.impl.engine.DefaultAsyncProcessorAwaitMa
Re: ProducerTemplate is waiting on something
Hi There is a mbean under services (I think) that has something with await manager - it has operations to list the blocked On Thu, May 4, 2023 at 8:01 PM Shultz, Dmitry wrote: > Thanks Claus, it helped a lot! > > I can see the ‘Exchanges Inflight’ number in the jconsole > org.apache.camel->routes->route-id->Attributes->Exchanges Inflight, but you > mentioned there is some way to see the list of actual exchanges. > What is the path in jconsole to see it? > > Dmitry > > > > From: Claus Ibsen > Sent: Thursday, May 4, 2023 4:05 AM > To: users@camel.apache.org > Subject: Re: ProducerTemplate is waiting on something > > Hi That indicates that a camel component is waiting for a reply that is > taking a very long time, or not happening, or a timeout is not being > triggered. You can use JMX and look in blocked exchanges to see a list and > where they are in the route, > ZjQcmQRYFpfptBannerStart > This Message Is From an External Sender > ZjQcmQRYFpfptBannerEnd > > Hi > > > > That indicates that a camel component is waiting for a reply that is taking > > a very long time, > > or not happening, or a timeout is not being triggered. > > > > You can use JMX and look in blocked exchanges to see a list and where they > > are in the route, and unblock them also. > > hawtio also have a page to show that. > > > > Also if you are using CXF then you can use it in synchronous=true mode as > > its async mode may cause this situation (it did that in the past) > > > > On Thu, May 4, 2023 at 12:44 AM Shultz, Dmitry <mailto:dmitry_shu...@kaltire.com>> > > wrote: > > > > > Hi All, > > > > > > We are having occasional problems with the some app using Camel 3.14.1 > > > rest routes and running in TomEE. After a while TomEE/Tomcat https > > > interface became unresponsive. > > > Looking at the thread dump I can see a lot of threads in such state: > > > > > > "https-jsse-nio-7443-exec-107" - Thread t@504 > > >java.lang.Thread.State: WAITING > > > at sun.misc.Unsafe.park(Native Method) > > > - parking to wait for <78a7fac3> (a > > > java.util.concurrent.CountDownLatch$Sync) > > > at > > > java.util.concurrent.locks.LockSupport.park(LockSupport.java:175) > > > at > > > > java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:836) > > > at > > > > java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:997) > > > at > > > > java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1304) > > > at > > > java.util.concurrent.CountDownLatch.await(CountDownLatch.java:231) > > > at > > > > org.apache.camel.impl.engine.DefaultAsyncProcessorAwaitManager.await(DefaultAsyncProcessorAwaitManager.java:107) > > > at > > > > org.apache.camel.impl.engine.DefaultAsyncProcessorAwaitManager.process(DefaultAsyncProcessorAwaitManager.java:85) > > > at > > > > org.apache.camel.impl.engine.SharedCamelInternalProcessor.process(SharedCamelInternalProcessor.java:108) > > > at > > > > org.apache.camel.support.cache.DefaultProducerCache.send(DefaultProducerCache.java:199) > > > at > > > > org.apache.camel.impl.engine.DefaultProducerTemplate.send(DefaultProducerTemplate.java:176) > > > at > > > > org.apache.camel.impl.engine.DefaultProducerTemplate.send(DefaultProducerTemplate.java:172) > > > at > > > > org.apache.camel.impl.engine.DefaultProducerTemplate.send(DefaultProducerTemplate.java:153) > > > at > > > > org.apache.camel.impl.engine.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:187) > > > at > > > > org.apache.camel.impl.engine.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:195) > > > at > > > > org.apache.camel.ProducerTemplate$$OwbNormalScopeProxy0.sendBody(org/apache/camel/ProducerTemplate.java) > > > > > >Locked ownable synchronizers: > > > - locked <59e6ab64> (a > > > java.util.concurrent.ThreadPoolExecutor$Worker) > > > > > > this is how ProducerTemplate is produced (CDI): > > > > > > @Produces > > > @ApplicationScoped > > > @MyProducerTemplate > > > ProducerTemplate getPro
RE: ProducerTemplate is waiting on something
Thanks Claus, it helped a lot! I can see the ‘Exchanges Inflight’ number in the jconsole org.apache.camel->routes->route-id->Attributes->Exchanges Inflight, but you mentioned there is some way to see the list of actual exchanges. What is the path in jconsole to see it? Dmitry From: Claus Ibsen Sent: Thursday, May 4, 2023 4:05 AM To: users@camel.apache.org Subject: Re: ProducerTemplate is waiting on something Hi That indicates that a camel component is waiting for a reply that is taking a very long time, or not happening, or a timeout is not being triggered. You can use JMX and look in blocked exchanges to see a list and where they are in the route, ZjQcmQRYFpfptBannerStart This Message Is From an External Sender ZjQcmQRYFpfptBannerEnd Hi That indicates that a camel component is waiting for a reply that is taking a very long time, or not happening, or a timeout is not being triggered. You can use JMX and look in blocked exchanges to see a list and where they are in the route, and unblock them also. hawtio also have a page to show that. Also if you are using CXF then you can use it in synchronous=true mode as its async mode may cause this situation (it did that in the past) On Thu, May 4, 2023 at 12:44 AM Shultz, Dmitry mailto:dmitry_shu...@kaltire.com>> wrote: > Hi All, > > We are having occasional problems with the some app using Camel 3.14.1 > rest routes and running in TomEE. After a while TomEE/Tomcat https > interface became unresponsive. > Looking at the thread dump I can see a lot of threads in such state: > > "https-jsse-nio-7443-exec-107" - Thread t@504 >java.lang.Thread.State: WAITING > at sun.misc.Unsafe.park(Native Method) > - parking to wait for <78a7fac3> (a > java.util.concurrent.CountDownLatch$Sync) > at > java.util.concurrent.locks.LockSupport.park(LockSupport.java:175) > at > java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:836) > at > java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:997) > at > java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1304) > at > java.util.concurrent.CountDownLatch.await(CountDownLatch.java:231) > at > org.apache.camel.impl.engine.DefaultAsyncProcessorAwaitManager.await(DefaultAsyncProcessorAwaitManager.java:107) > at > org.apache.camel.impl.engine.DefaultAsyncProcessorAwaitManager.process(DefaultAsyncProcessorAwaitManager.java:85) > at > org.apache.camel.impl.engine.SharedCamelInternalProcessor.process(SharedCamelInternalProcessor.java:108) > at > org.apache.camel.support.cache.DefaultProducerCache.send(DefaultProducerCache.java:199) > at > org.apache.camel.impl.engine.DefaultProducerTemplate.send(DefaultProducerTemplate.java:176) > at > org.apache.camel.impl.engine.DefaultProducerTemplate.send(DefaultProducerTemplate.java:172) > at > org.apache.camel.impl.engine.DefaultProducerTemplate.send(DefaultProducerTemplate.java:153) > at > org.apache.camel.impl.engine.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:187) > at > org.apache.camel.impl.engine.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:195) > at > org.apache.camel.ProducerTemplate$$OwbNormalScopeProxy0.sendBody(org/apache/camel/ProducerTemplate.java) > >Locked ownable synchronizers: > - locked <59e6ab64> (a > java.util.concurrent.ThreadPoolExecutor$Worker) > > this is how ProducerTemplate is produced (CDI): > > @Produces > @ApplicationScoped > @MyProducerTemplate > ProducerTemplate getProducerTemplate() { > return context.createProducerTemplate(); > } > > And this is how it is injected everywhere it is used (single > ApplicationScoped instance): > > @Inject > @MyProducerTemplate > ProducerTemplate producerTemplate; > > Is there anything wrong with re-using single instance? If not, what may be > the problem? > > Thanks, > Dmitry > > > > -- Claus Ibsen - @davsclaus Camel in Action 2: https://urldefense.com/v3/__https://www.manning.com/ibsen2__;!!LdWlNaMnLCM!aubXnsMfa8p3SGvMT22PbzynPg2GhFtqrjNMJf8wZfegju1ys3y474DqozOcS6QzNYI_-1xIEYHkk9n6UyiF1i8fWQ$<https://urldefense.com/v3/__https:/www.manning.com/ibsen2__;!!LdWlNaMnLCM!aubXnsMfa8p3SGvMT22PbzynPg2GhFtqrjNMJf8wZfegju1ys3y474DqozOcS6QzNYI_-1xIEYHkk9n6UyiF1i8fWQ$>
Re: ProducerTemplate is waiting on something
Hi That indicates that a camel component is waiting for a reply that is taking a very long time, or not happening, or a timeout is not being triggered. You can use JMX and look in blocked exchanges to see a list and where they are in the route, and unblock them also. hawtio also have a page to show that. Also if you are using CXF then you can use it in synchronous=true mode as its async mode may cause this situation (it did that in the past) On Thu, May 4, 2023 at 12:44 AM Shultz, Dmitry wrote: > Hi All, > > We are having occasional problems with the some app using Camel 3.14.1 > rest routes and running in TomEE. After a while TomEE/Tomcat https > interface became unresponsive. > Looking at the thread dump I can see a lot of threads in such state: > > "https-jsse-nio-7443-exec-107" - Thread t@504 >java.lang.Thread.State: WAITING > at sun.misc.Unsafe.park(Native Method) > - parking to wait for <78a7fac3> (a > java.util.concurrent.CountDownLatch$Sync) > at > java.util.concurrent.locks.LockSupport.park(LockSupport.java:175) > at > java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:836) > at > java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:997) > at > java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1304) > at > java.util.concurrent.CountDownLatch.await(CountDownLatch.java:231) > at > org.apache.camel.impl.engine.DefaultAsyncProcessorAwaitManager.await(DefaultAsyncProcessorAwaitManager.java:107) > at > org.apache.camel.impl.engine.DefaultAsyncProcessorAwaitManager.process(DefaultAsyncProcessorAwaitManager.java:85) > at > org.apache.camel.impl.engine.SharedCamelInternalProcessor.process(SharedCamelInternalProcessor.java:108) > at > org.apache.camel.support.cache.DefaultProducerCache.send(DefaultProducerCache.java:199) > at > org.apache.camel.impl.engine.DefaultProducerTemplate.send(DefaultProducerTemplate.java:176) > at > org.apache.camel.impl.engine.DefaultProducerTemplate.send(DefaultProducerTemplate.java:172) > at > org.apache.camel.impl.engine.DefaultProducerTemplate.send(DefaultProducerTemplate.java:153) > at > org.apache.camel.impl.engine.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:187) > at > org.apache.camel.impl.engine.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:195) > at > org.apache.camel.ProducerTemplate$$OwbNormalScopeProxy0.sendBody(org/apache/camel/ProducerTemplate.java) > > Locked ownable synchronizers: > - locked <59e6ab64> (a > java.util.concurrent.ThreadPoolExecutor$Worker) > > this is how ProducerTemplate is produced (CDI): > > @Produces > @ApplicationScoped > @MyProducerTemplate > ProducerTemplate getProducerTemplate() { > return context.createProducerTemplate(); > } > > And this is how it is injected everywhere it is used (single > ApplicationScoped instance): > > @Inject > @MyProducerTemplate > ProducerTemplate producerTemplate; > > Is there anything wrong with re-using single instance? If not, what may be > the problem? > > Thanks, > Dmitry > > > > -- Claus Ibsen - @davsclaus Camel in Action 2: https://www.manning.com/ibsen2
ProducerTemplate is waiting on something
Hi All, We are having occasional problems with the some app using Camel 3.14.1 rest routes and running in TomEE. After a while TomEE/Tomcat https interface became unresponsive. Looking at the thread dump I can see a lot of threads in such state: "https-jsse-nio-7443-exec-107" - Thread t@504 java.lang.Thread.State: WAITING at sun.misc.Unsafe.park(Native Method) - parking to wait for <78a7fac3> (a java.util.concurrent.CountDownLatch$Sync) at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175) at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:836) at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:997) at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1304) at java.util.concurrent.CountDownLatch.await(CountDownLatch.java:231) at org.apache.camel.impl.engine.DefaultAsyncProcessorAwaitManager.await(DefaultAsyncProcessorAwaitManager.java:107) at org.apache.camel.impl.engine.DefaultAsyncProcessorAwaitManager.process(DefaultAsyncProcessorAwaitManager.java:85) at org.apache.camel.impl.engine.SharedCamelInternalProcessor.process(SharedCamelInternalProcessor.java:108) at org.apache.camel.support.cache.DefaultProducerCache.send(DefaultProducerCache.java:199) at org.apache.camel.impl.engine.DefaultProducerTemplate.send(DefaultProducerTemplate.java:176) at org.apache.camel.impl.engine.DefaultProducerTemplate.send(DefaultProducerTemplate.java:172) at org.apache.camel.impl.engine.DefaultProducerTemplate.send(DefaultProducerTemplate.java:153) at org.apache.camel.impl.engine.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:187) at org.apache.camel.impl.engine.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:195) at org.apache.camel.ProducerTemplate$$OwbNormalScopeProxy0.sendBody(org/apache/camel/ProducerTemplate.java) Locked ownable synchronizers: - locked <59e6ab64> (a java.util.concurrent.ThreadPoolExecutor$Worker) this is how ProducerTemplate is produced (CDI): @Produces @ApplicationScoped @MyProducerTemplate ProducerTemplate getProducerTemplate() { return context.createProducerTemplate(); } And this is how it is injected everywhere it is used (single ApplicationScoped instance): @Inject @MyProducerTemplate ProducerTemplate producerTemplate; Is there anything wrong with re-using single instance? If not, what may be the problem? Thanks, Dmitry
Re: Sending with ProducerTemplate, how to marshal with ProtobufDataFormat
Hi Whatever you have in the body is what is sent, so you make sure it's in protobuf beforehand. On Tue, Apr 11, 2023 at 12:59 AM Steve973 wrote: > Hello. If I want to send a message with the ProducerTemplate, how do I > ensure that the body is marshaled by protobuf? > > Thanks, > Steve > -- Claus Ibsen - @davsclaus Camel in Action 2: https://www.manning.com/ibsen2
Sending with ProducerTemplate, how to marshal with ProtobufDataFormat
Hello. If I want to send a message with the ProducerTemplate, how do I ensure that the body is marshaled by protobuf? Thanks, Steve
Re: ProducerTemplate (or something similar) support in Camel JBang?
Hi On Wed, Feb 1, 2023 at 5:40 AM Mikael Koskinen wrote: > Hi, > > I've been wondering if it would be possible or a good idea to add > something like the ProducerTemplate to Camel JBang? I mean the ability > to send messages to running integrations using the CLI. > > Use case for me would be a scenario where I could start direct > endpoints when our application starts and then in specific points use > the CLI to send messages to these endpoints for processing. > > Best regards, > Mikael > Yes I have thought about something like that as well. We should also consider being able to use the running JVM to send message to external endpoints, for example a kafka topic or JMS queue. The Camel route may be from jms:cheese to bean blah And then you can to trigger this route by sending a message to jms:cheese. Today you would do this manually or via JMS client tools. This is of course a great way to do that to use the "real thing". But sometimes you also want to be quick and if Camel can help, then send via Camel. You are welcome to create a JIRA. -- Claus Ibsen - @davsclaus Camel in Action 2: https://www.manning.com/ibsen2
ProducerTemplate (or something similar) support in Camel JBang?
Hi, I've been wondering if it would be possible or a good idea to add something like the ProducerTemplate to Camel JBang? I mean the ability to send messages to running integrations using the CLI. Use case for me would be a scenario where I could start direct endpoints when our application starts and then in specific points use the CLI to send messages to these endpoints for processing. Best regards, Mikael
Re: producerTemplate gets blocked calling back to previous OSGI bundle
Hi, It looks like a change in the Camel routing engine (DefaultAsyncProcessorAwaitManager). Let me take a look. Regards JB On Wed, Jun 1, 2022 at 8:21 PM Wing, Lucas A (US) wrote: > > Hey guys, question about some camel functionality. > > Java version: jdk1.8.0_152 > Karaf version: 4.3.2 (I also tested 4.3.7, and it has the same odd behavior) > Camel version: 3.11.0 (I also tested 3.14.0, and it has the same odd > behavior) > > In a clean karaf install, I created two different bundles. TestService1 and > TestService2. > TestService1 sends message to TestService2, then TestService2 uses > producerTemplate to hit a route on TestService1. > > That producerTemplate call appears to get stuck forever on an internal block. > If I do the same call without using producerTemplate (aka with to() or > Recipient List), it works fine. > > This did work in karaf 4.1.5 & camel 2.21.0, but appears to have stopped > functioning when I tried the versions stated above. > I guess my question here is, is this a bug? Or is this some sort of > functionality to prevent looping routes. > It only seems to happen if it's two separate bundles (and thus separate camel > contexts) so I'd guess this is a bug, but I'm unsure. > > If anyone happens to know any way around this possible issue as well, that'd > be great to know. > The only ways I've found is calling producerTemplate in a new thread (not a > good solution), or just outright avoiding the use of producerTemplate (even > worse solution). > > > Stack trace when I forcibly killed the thread: > > > Caused by: java.lang.InterruptedException > at > java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:998) > at > java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1304) > at java.util.concurrent.CountDownLatch.await(CountDownLatch.java:231) > at > org.apache.camel.impl.engine.DefaultAsyncProcessorAwaitManager.await(DefaultAsyncProcessorAwaitManager.java:107) > at > org.apache.camel.impl.engine.DefaultAsyncProcessorAwaitManager.process(DefaultAsyncProcessorAwaitManager.java:85) > at > org.apache.camel.impl.engine.SharedCamelInternalProcessor.process(SharedCamelInternalProcessor.java:108) > at > org.apache.camel.support.cache.DefaultProducerCache.send(DefaultProducerCache.java:190) > at > org.apache.camel.impl.engine.DefaultProducerTemplate.send(DefaultProducerTemplate.java:176) > at > org.apache.camel.impl.engine.DefaultProducerTemplate.send(DefaultProducerTemplate.java:172) > at > org.apache.camel.impl.engine.DefaultProducerTemplate.send(DefaultProducerTemplate.java:137) > > Code: > > > classes: > > public class TestService1 extends RouteBuilder { > > private static final Logger logger = > LoggerFactory.getLogger(TestService1.class); > > public static final String TEST_SERVICE2_ROUTE = > "direct-vm://testService2Route"; > public static final String TEST_SERVICE1_RETURN_ROUTE = > "direct-vm://testService1ReturnRoute"; > > @Override > public void configure() throws Exception { > > // On startup, send message to second jar/camel context > from("timer://startup?repeatCount=1=30s") > .routeId("startup") > .to(TEST_SERVICE2_ROUTE); > > // Listens for return call from second jar > from(TEST_SERVICE1_RETURN_ROUTE).routeId("testService1ReturnRoute") > .bean(this, "returnedMethod"); > } > > public void returnedMethod() { > logger.info("Made it back to the first jar!!!"); > } > > } > > public class TestService2 extends RouteBuilder { > > private static final Logger logger = > LoggerFactory.getLogger(TestService2.class); > > public static final String TEST_SERVICE2_ROUTE = > "direct-vm://testService2Route"; > public static final String TEST_SERVICE1_RETURN_ROUTE = > "direct-vm://testService1ReturnRoute"; > > @Produce(TEST_SERVICE1_RETURN_ROUTE) > ProducerTemplate executor; > > @Override > public void configure() throws Exception { > > //listens for a call from service 1, then hits a route in service 1 > from(TEST_SERVICE2_ROUTE).routeId("testService2Route") > .bean(this, "hitService1"); > > } > > public void hitService1() { > logger.info("This call gets locked up"); > executor.sendBody("hello");
producerTemplate gets blocked calling back to previous OSGI bundle
Hey guys, question about some camel functionality. Java version: jdk1.8.0_152 Karaf version: 4.3.2 (I also tested 4.3.7, and it has the same odd behavior) Camel version: 3.11.0 (I also tested 3.14.0, and it has the same odd behavior) In a clean karaf install, I created two different bundles. TestService1 and TestService2. TestService1 sends message to TestService2, then TestService2 uses producerTemplate to hit a route on TestService1. That producerTemplate call appears to get stuck forever on an internal block. If I do the same call without using producerTemplate (aka with to() or Recipient List), it works fine. This did work in karaf 4.1.5 & camel 2.21.0, but appears to have stopped functioning when I tried the versions stated above. I guess my question here is, is this a bug? Or is this some sort of functionality to prevent looping routes. It only seems to happen if it's two separate bundles (and thus separate camel contexts) so I'd guess this is a bug, but I'm unsure. If anyone happens to know any way around this possible issue as well, that'd be great to know. The only ways I've found is calling producerTemplate in a new thread (not a good solution), or just outright avoiding the use of producerTemplate (even worse solution). Stack trace when I forcibly killed the thread: Caused by: java.lang.InterruptedException at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:998) at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1304) at java.util.concurrent.CountDownLatch.await(CountDownLatch.java:231) at org.apache.camel.impl.engine.DefaultAsyncProcessorAwaitManager.await(DefaultAsyncProcessorAwaitManager.java:107) at org.apache.camel.impl.engine.DefaultAsyncProcessorAwaitManager.process(DefaultAsyncProcessorAwaitManager.java:85) at org.apache.camel.impl.engine.SharedCamelInternalProcessor.process(SharedCamelInternalProcessor.java:108) at org.apache.camel.support.cache.DefaultProducerCache.send(DefaultProducerCache.java:190) at org.apache.camel.impl.engine.DefaultProducerTemplate.send(DefaultProducerTemplate.java:176) at org.apache.camel.impl.engine.DefaultProducerTemplate.send(DefaultProducerTemplate.java:172) at org.apache.camel.impl.engine.DefaultProducerTemplate.send(DefaultProducerTemplate.java:137) Code: classes: public class TestService1 extends RouteBuilder { private static final Logger logger = LoggerFactory.getLogger(TestService1.class); public static final String TEST_SERVICE2_ROUTE = "direct-vm://testService2Route"; public static final String TEST_SERVICE1_RETURN_ROUTE = "direct-vm://testService1ReturnRoute"; @Override public void configure() throws Exception { // On startup, send message to second jar/camel context from("timer://startup?repeatCount=1=30s") .routeId("startup") .to(TEST_SERVICE2_ROUTE); // Listens for return call from second jar from(TEST_SERVICE1_RETURN_ROUTE).routeId("testService1ReturnRoute") .bean(this, "returnedMethod"); } public void returnedMethod() { logger.info("Made it back to the first jar!!!"); } } public class TestService2 extends RouteBuilder { private static final Logger logger = LoggerFactory.getLogger(TestService2.class); public static final String TEST_SERVICE2_ROUTE = "direct-vm://testService2Route"; public static final String TEST_SERVICE1_RETURN_ROUTE = "direct-vm://testService1ReturnRoute"; @Produce(TEST_SERVICE1_RETURN_ROUTE) ProducerTemplate executor; @Override public void configure() throws Exception { //listens for a call from service 1, then hits a route in service 1 from(TEST_SERVICE2_ROUTE).routeId("testService2Route") .bean(this, "hitService1"); } public void hitService1() { logger.info("This call gets locked up"); executor.sendBody("hello"); } } blueprints: http://www.osgi.org/xmlns/blueprint/v1.0.0; xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd;> http://camel.apache.org/schema/blueprint;> http://www.osgi.org/xmlns/blueprint/v1.0.0; xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd;> http://camel.apache.org/schema/blueprint;>
Re: Give me suggestions about how to use ProducerTemplate correctly please
Hi See this FAQ https://camel.apache.org/manual/faq/why-does-camel-use-too-many-threads-with-producertemplate.html You do not create a template per message you send, you create it once / or better you dependency inject it into the route builder. Since you use spring you can use @Autowired or @Inject etc On Wed, Nov 3, 2021 at 12:25 PM Vyacheslav Boyko wrote: > > Hello. > > I have faced with important notice in JavaDoc of > org.apache.camel.CamelContext#createProducerTemplate() and it makes me > rethink how to use it. > > JavaDoc prescribes: Important: Make sure to call ProducerTemplate.stop() > when you are done using the template, to clean up any resources. > > So, when I implement RouteBuilder in SpringBoot project I make it like: > > @Component > class BusinessRouteBuilder extends RouteBuilder { >@Override >public void configure() { > from("seda://start") >.to("seda://business-start"); // to process in separated thread >} >public void sendMessage(Msg msg) { > getContext().createProducerTemplate().sendBody("seda://start", msg); > } > } > > > My question and concern is: am I doing it correctly? > > It seems I have to stop ProducerTemplate created before. But where to > close it? Right after it was used in sendMessage() like the following? > >public void sendMessage(Msg msg) { > ProducerTemplate producerTemplate = > getContext().createProducerTemplate(); > producerTemplate.sendBody("seda://start", msg); > producerTemplate.stop(); >} > > Or maybe it will be better to create one ProducerTemplate per Spring > bean and to stop it in @PreDestroy method like the following? > > @Component > class BusinessRouteBuilder extends RouteBuilder { >ProducerTemplate producerTemplate; >@Override >public void configure() { > producerTemplate = getContext().createProducerTemplate(); > from("seda://start") >.to("seda://business-start"); // to process in separated thread >} >public void sendMessage(Msg msg) { > producerTemplate.sendBody("seda://start", msg); >} >@PreDestroy >public void preDestroy() { > producerTemplate.stop(); >} > } > > ___ > Vyacheslav Boyko > mailto:mail4...@gmail.com > -- Claus Ibsen - http://davsclaus.com @davsclaus Camel in Action 2: https://www.manning.com/ibsen2
Give me suggestions about how to use ProducerTemplate correctly please
Hello. I have faced with important notice in JavaDoc of org.apache.camel.CamelContext#createProducerTemplate() and it makes me rethink how to use it. JavaDoc prescribes: Important: Make sure to call ProducerTemplate.stop() when you are done using the template, to clean up any resources. So, when I implement RouteBuilder in SpringBoot project I make it like: @Component class BusinessRouteBuilder extends RouteBuilder { @Override public void configure() { from("seda://start") .to("seda://business-start"); // to process in separated thread } public void sendMessage(Msg msg) { getContext().createProducerTemplate().sendBody("seda://start", msg); } } My question and concern is: am I doing it correctly? It seems I have to stop ProducerTemplate created before. But where to close it? Right after it was used in sendMessage() like the following? public void sendMessage(Msg msg) { ProducerTemplate producerTemplate = getContext().createProducerTemplate(); producerTemplate.sendBody("seda://start", msg); producerTemplate.stop(); } Or maybe it will be better to create one ProducerTemplate per Spring bean and to stop it in @PreDestroy method like the following? @Component class BusinessRouteBuilder extends RouteBuilder { ProducerTemplate producerTemplate; @Override public void configure() { producerTemplate = getContext().createProducerTemplate(); from("seda://start") .to("seda://business-start"); // to process in separated thread } public void sendMessage(Msg msg) { producerTemplate.sendBody("seda://start", msg); } @PreDestroy public void preDestroy() { producerTemplate.stop(); } } ___ Vyacheslav Boyko mailto:mail4...@gmail.com
direct-vm blocked in Camel 3.1 and up when using ProducerTemplate
Hello- We are seeing an issue when we have 2 camel context communicating with each other via direct-vm calls but only when we are using the ProducerTemplate.sendBody to send a direct-vm message back to an endpoint within a camel context that initially started the process. We are only seeing this issue after migrating from camel-blueprint from org.apache.camel 2.17.3 to org.apache.camel.karaf 3.7.1. After testing multiple versions of camel-blueprint it seems that the issue was introduced in version 3.1.0; versions that are equal or below version 2.25.3 seem to work fine. We have provide some information below to show the issue when comparing version 2.25.3 and 3.1.0. However, we are seeing the same issue with org.apache.camel.karaf 3.7.1 and only when using direct-vm. For the given scenarios below we are using the bean "testRouting" that will send a message via ProducerTemplate within the camel-context-2 public class TestRouting { @Produce protected ProducerTemplate producer; public void sentToDirectVm() { Map properties = new HashMap(); properties.put("key1", "value1"); properties.put("key2", "value2"); properties.put("key3", "value3"); producer.sendBody("direct-vm:CamelContext2_Route2", properties); } } Scenario 1: - Bundle cedi-camel-context-1 will send a message via route CamelContext1_Route1 using a direct-vm to cedi-camel-context-2 route CamelContext2_Route1. - The message gets consumed by route CamelContext2_Route1 and will try to send a direct-vm message back to cedi-camel-context-1 route CamelContext2_Route2 using the ProducerTemplate.sendBody bundle: cedi-camel-context-1 blueprint: camel-context-1-blueprint.xml camelContext: CamelContext1 http://www.osgi.org/xmlns/blueprint/v1.0.0; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd<http://www.osgi.org/xmlns/blueprint/v1.0.0%20http:/www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd>"> http://camel.apache.org/schema/blueprint;> bundle: cedi-camel-context-2 blueprint: camel-context-2-blueprint.xml camelContext: CamelContext2 http://www.osgi.org/xmlns/blueprint/v1.0.0; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd<http://www.osgi.org/xmlns/blueprint/v1.0.0%20http:/www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd>"> http://camel.apache.org/schema/blueprint;> - When using camel-blueprint 3.1.0 or greater; it appears that message going back to cedi-camel-context-1 does not get consumer or is being blocked. Log file - Forcing the routes to be shutdown 2021-03-15T14:58:52,029 | WARN | FelixShutdown| DefaultAsyncProcessorAwaitManager | 55 - org.apache.camel.camel-base - 3.1.0 | Shutting down while there are still 1 inflight threads currently blocked. 2021-03-15T14:58:52,030 | WARN | FelixShutdown| DefaultAsyncProcessorAwaitManager | 55 - org.apache.camel.camel-base - 3.1.0 | The following threads are blocked and will be interrupted so the threads are released: Blocked Thread --- Id: 250 Name: Camel (CamelContext1) thread #1 - scheduler://foo1 RouteId: NodeId: Duration: 902873 msec. 2021-03-15T14:58:52,033 | WARN | FelixShutdown| DefaultAsyncProcessorAwaitManager | 55 - org.apache.camel.camel-base - 3.1.0 | Interrupted while waiting for asynchronous callback, will release the following blocked thread which was waiting for exchange to finish processing with exchangeId: ID-edidev02262001-1615833829150-1-2 Blocked Thread --- Id: 250 Name: Camel (CamelContext1) thread #1 - scheduler://foo1 RouteId: NodeId: Duration: 902873 msec. Message History (complete message history is disabled) --- RouteId ProcessorId Processor
Re: netty-http @Produce / ProducerTemplate
Hi Ah okay, can you create a JIRA ticket so we wont forget. On Wed, Apr 29, 2020 at 5:53 PM iandi2011-onl...@yahoo.com.INVALID wrote: > > Hello, > > > according to > https://camel.apache.org/components/latest/netty-http-component.html this > should work : netty-http:http://0.0.0.0:8080[?options] > > > In my camel 3.2 spring-boot test environment I try this : > > >org.apache.camel.springboot >camel-netty-http-starter > > > > @Produce(value="netty-http:http://localhost:8765/foo?encoders=#objectEncoder=#objectDecoder;) > private ProducerTemplate template; > > > with this result : > > > 2020-04-29 16:02:31.006 ERROR nbo00018456 --- [main] > o.s.t.c.TestContextManager : Caught exception while allowing > TestExecutionListener > [org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener@4ddbbdf8] > to prepare test instance > [de.muenchen.dept.eai.dms.consumer.DepartmentClientTest@56dfab87] > > org.apache.camel.spring.GenericBeansException: Error post processing bean: > de.muenchen.dept.eai.dms.consumer.DepartmentClientTest.ORIGINAL; nested > exception is org.apache.camel.NoSuchEndpointException: No endpoint could be > found for: http://localhost:8765/dms1, please check your classpath contains > the needed Camel component jar. >at > org.apache.camel.spring.CamelBeanPostProcessor.postProcessBeforeInitialization(CamelBeanPostProcessor.java:168) >at > org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:416) >at > org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1788) > >at > org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:407) >at > org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:120) >at > org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:83) >at > org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener.prepareTestInstance(SpringBootDependencyInjectionTestExecutionListener.java:43) >at > org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:244) >at > org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:227) >at > org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289) >at > org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) >at > org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291) > >at > org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:246) > >at > org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97) >at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331) >at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79) >at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329) >at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66) >at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293) >at > org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) >at > org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) >at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) >at org.junit.runners.ParentRunner.run(ParentRunner.java:413) >at > org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190) >at org.junit.runner.JUnitCore.run(JUnitCore.java:137) >at org.junit.runner.JUnitCore.run(JUnitCore.java:115) >at > org.junit.vintage.engine.execution.RunnerExecutor.execute(RunnerExecutor.java:43) >at > java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184) >at > java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) >at java.util.Iterator.forEachRemaining(Iterator.java:116) &g
netty-http @Produce / ProducerTemplate
Hello, according to https://camel.apache.org/components/latest/netty-http-component.html this should work : netty-http:http://0.0.0.0:8080[?options] In my camel 3.2 spring-boot test environment I try this : org.apache.camel.springboot camel-netty-http-starter @Produce(value="netty-http:http://localhost:8765/foo?encoders=#objectEncoder=#objectDecoder;) private ProducerTemplate template; with this result : 2020-04-29 16:02:31.006 ERROR nbo00018456 --- [main] o.s.t.c.TestContextManager : Caught exception while allowing TestExecutionListener [org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener@4ddbbdf8] to prepare test instance [de.muenchen.dept.eai.dms.consumer.DepartmentClientTest@56dfab87] org.apache.camel.spring.GenericBeansException: Error post processing bean: de.muenchen.dept.eai.dms.consumer.DepartmentClientTest.ORIGINAL; nested exception is org.apache.camel.NoSuchEndpointException: No endpoint could be found for: http://localhost:8765/dms1, please check your classpath contains the needed Camel component jar. at org.apache.camel.spring.CamelBeanPostProcessor.postProcessBeforeInitialization(CamelBeanPostProcessor.java:168) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:416) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1788) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:407) at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:120) at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:83) at org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener.prepareTestInstance(SpringBootDependencyInjectionTestExecutionListener.java:43) at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:244) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:227) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:246) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97) at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329) at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) at org.junit.runners.ParentRunner.run(ParentRunner.java:413) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at org.junit.runner.JUnitCore.run(JUnitCore.java:115) at org.junit.vintage.engine.execution.RunnerExecutor.execute(RunnerExecutor.java:43) at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184) at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) at java.util.Iterator.forEachRemaining(Iterator.java:116) at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801) at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482) at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151) at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174) at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.util.stream.ReferencePipeline.fo
Re: No ExchangeSentEvent in @Produce but is in ProducerTemplate
Hi I logged a ticket and are working on to add this in camel 3 https://issues.apache.org/jira/browse/CAMEL-13199 On Thu, Feb 14, 2019 at 9:46 AM Claus Ibsen wrote: > > Hi > > Yeah this is currently not supported, you are welcome to log a JIRA ticket > > On Tue, Feb 12, 2019 at 10:58 PM Garner, Kevin > wrote: > > > > We're using EventNotifier and ExchangeSentEvent to log timing of certain > > direct:// routes and we've run into a problem when using @Produce instead > > of ProducerTemplate. > > > > When sending exchange to producer template, ExchangeSentEvent is fired > > after exchange is sent. Same when it's part of a larger route. Not so much > > with @Produce. > > > > Any guidance on how to use @Produce but still trigger the events? > > > > I've got a unit test below - notifyProxy fails, but the other cases pass. > > Camel 2.23.0 > > > > Thanks, > > Kevin > > > > > > > > > > > > > > > > import static org.hamcrest.CoreMatchers.equalTo; > > import static org.hamcrest.CoreMatchers.notNullValue; > > import static org.junit.Assert.assertThat; > > import static org.junit.Assert.assertTrue; > > > > import java.util.EventObject; > > > > import org.apache.camel.Body; > > import org.apache.camel.CamelContext; > > import org.apache.camel.Exchange; > > import org.apache.camel.Produce; > > import org.apache.camel.ProducerTemplate; > > import org.apache.camel.builder.RouteBuilder; > > import org.apache.camel.impl.DefaultExchange; > > import org.apache.camel.management.event.ExchangeSentEvent; > > import org.apache.camel.spring.javaconfig.CamelConfiguration; > > import org.apache.camel.support.EventNotifierSupport; > > import org.apache.camel.test.spring.CamelSpringRunner; > > import org.apache.camel.util.EndpointHelper; > > import org.apache.camel.util.ServiceHelper; > > import org.junit.Before; > > import org.junit.Test; > > import org.junit.runner.RunWith; > > import org.springframework.beans.factory.annotation.Autowired; > > import org.springframework.context.annotation.Bean; > > import org.springframework.context.annotation.Configuration; > > import org.springframework.test.context.ContextConfiguration; > > > > @RunWith(CamelSpringRunner.class) > > @ContextConfiguration(classes = { CamelConfiguration.class, > > DirectTest.TestConfig.class }) > > public class DirectTest { > >private static final String NAME = "Doug"; > >private static final String EXPECTED = "Hello, 'Doug'"; > > > >@Produce(uri = HelloApi.ROUTE) > >private HelloApi helloApi; > > > >@Produce(uri = HelloApi.ROUTE) > >private ProducerTemplate helloApiTemplate; > > > >@Produce(uri = HelloApi.WRAPPED_ROUTE) > >private HelloApi helloApiWrapped; > > > >@Autowired > >private CamelContext camelContext; > >private HelloSentEventNotifier eventNotifier; > > > >@Before > >public void setup() throws Exception { > > assertThat(helloApi, notNullValue()); > > assertThat(helloApiTemplate, notNullValue()); > > > > eventNotifier = new HelloSentEventNotifier(camelContext); > >} > > > >@Test > >public void notifyTemplate() { > > eventNotifier.reset(); > > Exchange e = new DefaultExchange(camelContext); > > e.getIn().setBody(NAME); > > e = helloApiTemplate.send(e); > > String output = e.getOut().getBody(String.class); > > assertThat(output, equalTo(EXPECTED)); > > assertTrue("ExchangeSentEvent not received", > > eventNotifier.notified()); > >} > > > >@Test > >public void notifyProxy() { > > eventNotifier.reset(); > > String output = helloApi.sayHello(NAME); > > assertThat(output, equalTo(EXPECTED)); > > assertTrue("ExchangeSentEvent not received", > > eventNotifier.notified()); > >} > > > >@Test > >public void notifyWrappedProxy() { > > eventNotifier.reset(); > > String output = helloApiWrapped.sayHello(NAME); > > assertThat(output, equalTo(EXPECTED)); > > assertTrue("ExchangeSentEvent not received"
Re: No ExchangeSentEvent in @Produce but is in ProducerTemplate
Hi Yeah this is currently not supported, you are welcome to log a JIRA ticket On Tue, Feb 12, 2019 at 10:58 PM Garner, Kevin wrote: > > We're using EventNotifier and ExchangeSentEvent to log timing of certain > direct:// routes and we've run into a problem when using @Produce instead of > ProducerTemplate. > > When sending exchange to producer template, ExchangeSentEvent is fired after > exchange is sent. Same when it's part of a larger route. Not so much with > @Produce. > > Any guidance on how to use @Produce but still trigger the events? > > I've got a unit test below - notifyProxy fails, but the other cases pass. > Camel 2.23.0 > > Thanks, > Kevin > > > > > > > > import static org.hamcrest.CoreMatchers.equalTo; > import static org.hamcrest.CoreMatchers.notNullValue; > import static org.junit.Assert.assertThat; > import static org.junit.Assert.assertTrue; > > import java.util.EventObject; > > import org.apache.camel.Body; > import org.apache.camel.CamelContext; > import org.apache.camel.Exchange; > import org.apache.camel.Produce; > import org.apache.camel.ProducerTemplate; > import org.apache.camel.builder.RouteBuilder; > import org.apache.camel.impl.DefaultExchange; > import org.apache.camel.management.event.ExchangeSentEvent; > import org.apache.camel.spring.javaconfig.CamelConfiguration; > import org.apache.camel.support.EventNotifierSupport; > import org.apache.camel.test.spring.CamelSpringRunner; > import org.apache.camel.util.EndpointHelper; > import org.apache.camel.util.ServiceHelper; > import org.junit.Before; > import org.junit.Test; > import org.junit.runner.RunWith; > import org.springframework.beans.factory.annotation.Autowired; > import org.springframework.context.annotation.Bean; > import org.springframework.context.annotation.Configuration; > import org.springframework.test.context.ContextConfiguration; > > @RunWith(CamelSpringRunner.class) > @ContextConfiguration(classes = { CamelConfiguration.class, > DirectTest.TestConfig.class }) > public class DirectTest { >private static final String NAME = "Doug"; >private static final String EXPECTED = "Hello, 'Doug'"; > >@Produce(uri = HelloApi.ROUTE) >private HelloApi helloApi; > >@Produce(uri = HelloApi.ROUTE) >private ProducerTemplate helloApiTemplate; > >@Produce(uri = HelloApi.WRAPPED_ROUTE) >private HelloApi helloApiWrapped; > >@Autowired >private CamelContext camelContext; >private HelloSentEventNotifier eventNotifier; > >@Before >public void setup() throws Exception { > assertThat(helloApi, notNullValue()); > assertThat(helloApiTemplate, notNullValue()); > > eventNotifier = new HelloSentEventNotifier(camelContext); >} > >@Test >public void notifyTemplate() { > eventNotifier.reset(); > Exchange e = new DefaultExchange(camelContext); > e.getIn().setBody(NAME); > e = helloApiTemplate.send(e); > String output = e.getOut().getBody(String.class); > assertThat(output, equalTo(EXPECTED)); > assertTrue("ExchangeSentEvent not received", > eventNotifier.notified()); >} > >@Test >public void notifyProxy() { > eventNotifier.reset(); > String output = helloApi.sayHello(NAME); > assertThat(output, equalTo(EXPECTED)); > assertTrue("ExchangeSentEvent not received", > eventNotifier.notified()); >} > >@Test >public void notifyWrappedProxy() { > eventNotifier.reset(); > String output = helloApiWrapped.sayHello(NAME); > assertThat(output, equalTo(EXPECTED)); > assertTrue("ExchangeSentEvent not received", > eventNotifier.notified()); >} > >@Configuration >public static class TestConfig { > @Bean > public RouteBuilder builder() { > return new RouteBuilder() { >@Override >public void configure() throws Exception { > from(HelloApi.ROUTE).process(e -> { > String name = > e.getIn().getBody(String.class); > String output = > String.format("Hello, '%s'", name); > e.getOut().setBody(output); >
No ExchangeSentEvent in @Produce but is in ProducerTemplate
We're using EventNotifier and ExchangeSentEvent to log timing of certain direct:// routes and we've run into a problem when using @Produce instead of ProducerTemplate. When sending exchange to producer template, ExchangeSentEvent is fired after exchange is sent. Same when it's part of a larger route. Not so much with @Produce. Any guidance on how to use @Produce but still trigger the events? I've got a unit test below - notifyProxy fails, but the other cases pass. Camel 2.23.0 Thanks, Kevin import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.notNullValue; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import java.util.EventObject; import org.apache.camel.Body; import org.apache.camel.CamelContext; import org.apache.camel.Exchange; import org.apache.camel.Produce; import org.apache.camel.ProducerTemplate; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.impl.DefaultExchange; import org.apache.camel.management.event.ExchangeSentEvent; import org.apache.camel.spring.javaconfig.CamelConfiguration; import org.apache.camel.support.EventNotifierSupport; import org.apache.camel.test.spring.CamelSpringRunner; import org.apache.camel.util.EndpointHelper; import org.apache.camel.util.ServiceHelper; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.test.context.ContextConfiguration; @RunWith(CamelSpringRunner.class) @ContextConfiguration(classes = { CamelConfiguration.class, DirectTest.TestConfig.class }) public class DirectTest { private static final String NAME = "Doug"; private static final String EXPECTED = "Hello, 'Doug'"; @Produce(uri = HelloApi.ROUTE) private HelloApi helloApi; @Produce(uri = HelloApi.ROUTE) private ProducerTemplate helloApiTemplate; @Produce(uri = HelloApi.WRAPPED_ROUTE) private HelloApi helloApiWrapped; @Autowired private CamelContext camelContext; private HelloSentEventNotifier eventNotifier; @Before public void setup() throws Exception { assertThat(helloApi, notNullValue()); assertThat(helloApiTemplate, notNullValue()); eventNotifier = new HelloSentEventNotifier(camelContext); } @Test public void notifyTemplate() { eventNotifier.reset(); Exchange e = new DefaultExchange(camelContext); e.getIn().setBody(NAME); e = helloApiTemplate.send(e); String output = e.getOut().getBody(String.class); assertThat(output, equalTo(EXPECTED)); assertTrue("ExchangeSentEvent not received", eventNotifier.notified()); } @Test public void notifyProxy() { eventNotifier.reset(); String output = helloApi.sayHello(NAME); assertThat(output, equalTo(EXPECTED)); assertTrue("ExchangeSentEvent not received", eventNotifier.notified()); } @Test public void notifyWrappedProxy() { eventNotifier.reset(); String output = helloApiWrapped.sayHello(NAME); assertThat(output, equalTo(EXPECTED)); assertTrue("ExchangeSentEvent not received", eventNotifier.notified()); } @Configuration public static class TestConfig { @Bean public RouteBuilder builder() { return new RouteBuilder() { @Override public void configure() throws Exception { from(HelloApi.ROUTE).process(e -> { String name = e.getIn().getBody(String.class); String output = String.format("Hello, '%s'", name); e.getOut().setBody(output); }); from(HelloApi.WRAPPED_ROUTE).to(HelloApi.ROUTE); } }; } } public static interface HelloApi { public static final String ROUTE = "direct://hello"; public static final String WRAPPED_ROUTE = ROUTE + "/wrapper"; public String sayHello(@Body String name); } public static class HelloSentEventNotifier extends EventNotifierSupport { private boolean notified = false; private CamelContext camelContext; public HelloSentEventNotifier(CamelContext camelContext
Re: how could I get multiple different ProducerTemplate instances with Auto-Configured Producer Templates
Btw mind that in very latest Camel releases we have optimised the http endpoints to try to auto-detect the dynamic aspects of the context-path and optimise themselves. So in that case you may not need to use the header. But I cannot recall without looking in the source, whether we allowed this optimisation to happen on producer template level too (in routes it would do it) On Mon, Dec 3, 2018 at 7:18 PM Claus Ibsen wrote: > > Hi > > No you can use the same template to send to multiple endpoints. > > Just beware that sending to unlimited number of endpoints uris is not > a good practice as an endpoint / producer takes up resource. So in > your case with the HTTP endpoint, then its better to use a static uri > for the hostname and then a header with the dynamic context-path, then > you reuse the same endpoint / producer when doing network connection > to the remote http server. > > > On Thu, Nov 29, 2018 at 12:42 AM Wang Yan wrote: > > > > If I use the auto configured ProducerTemplate, how could I get multiple > > different ProducerTemplate instances? > > > > for example I need use producer template send different exchanges to > > different endpoints > > in this case, Do i need different producer template instances? if yes how ? > > Auto-Configured Consumer and Producer Templates > > > > Camel auto-configuration provides pre-configured *ConsumerTemplate* and > > *ProducerTemplate* instances. You can simply inject them into your > > Spring-managed beans: > > > > @Component > > public class InvoiceProcessor { > > > > @Autowired > > private ProducerTemplate producerTemplate; > > > > @Autowired > > private ConsumerTemplate consumerTemplate; > > public void processNextInvoice() { > > Invoice invoice = consumerTemplate.receiveBody("jms:invoices", > > Invoice.class); > > ... > > producerTemplate.sendBody("netty-http:http://invoicing.com/received/; > > + invoice.id()); > > } > > } > > > > -- > Claus Ibsen > - > http://davsclaus.com @davsclaus > Camel in Action 2: https://www.manning.com/ibsen2 -- Claus Ibsen - http://davsclaus.com @davsclaus Camel in Action 2: https://www.manning.com/ibsen2
Re: how could I get multiple different ProducerTemplate instances with Auto-Configured Producer Templates
Hi No you can use the same template to send to multiple endpoints. Just beware that sending to unlimited number of endpoints uris is not a good practice as an endpoint / producer takes up resource. So in your case with the HTTP endpoint, then its better to use a static uri for the hostname and then a header with the dynamic context-path, then you reuse the same endpoint / producer when doing network connection to the remote http server. On Thu, Nov 29, 2018 at 12:42 AM Wang Yan wrote: > > If I use the auto configured ProducerTemplate, how could I get multiple > different ProducerTemplate instances? > > for example I need use producer template send different exchanges to > different endpoints > in this case, Do i need different producer template instances? if yes how ? > Auto-Configured Consumer and Producer Templates > > Camel auto-configuration provides pre-configured *ConsumerTemplate* and > *ProducerTemplate* instances. You can simply inject them into your > Spring-managed beans: > > @Component > public class InvoiceProcessor { > > @Autowired > private ProducerTemplate producerTemplate; > > @Autowired > private ConsumerTemplate consumerTemplate; > public void processNextInvoice() { > Invoice invoice = consumerTemplate.receiveBody("jms:invoices", > Invoice.class); > ... > producerTemplate.sendBody("netty-http:http://invoicing.com/received/; > + invoice.id()); > } > } -- Claus Ibsen - http://davsclaus.com @davsclaus Camel in Action 2: https://www.manning.com/ibsen2
how could I get multiple different ProducerTemplate instances with Auto-Configured Producer Templates
If I use the auto configured ProducerTemplate, how could I get multiple different ProducerTemplate instances? for example I need use producer template send different exchanges to different endpoints in this case, Do i need different producer template instances? if yes how ? Auto-Configured Consumer and Producer Templates Camel auto-configuration provides pre-configured *ConsumerTemplate* and *ProducerTemplate* instances. You can simply inject them into your Spring-managed beans: @Component public class InvoiceProcessor { @Autowired private ProducerTemplate producerTemplate; @Autowired private ConsumerTemplate consumerTemplate; public void processNextInvoice() { Invoice invoice = consumerTemplate.receiveBody("jms:invoices", Invoice.class); ... producerTemplate.sendBody("netty-http:http://invoicing.com/received/; + invoice.id()); } }
how could I get multiple different ProducerTemplate instances with Auto-Configured Producer Templates
If I use the auto configured ProducerTemplate, how could I get multiple different ProducerTemplate instances? for example I need use producer template send different exchanges to different endpoints in this case, Do i need different producer template instances? if yes how ? Any suggestions ? Auto-Configured Consumer and Producer Templates Camel auto-configuration provides pre-configured *ConsumerTemplate* and *ProducerTemplate* instances. You can simply inject them into your Spring-managed beans: @Component public class InvoiceProcessor { @Autowired private ProducerTemplate producerTemplate; @Autowired private ConsumerTemplate consumerTemplate; public void processNextInvoice() { Invoice invoice = consumerTemplate.receiveBody("jms:invoices", Invoice.class); ... producerTemplate.sendBody("netty-http:http://invoicing.com/received/; + invoice.id()); } }
Re: Mandatory flag when send a rabbitmq message using ProducerTemplate
Hi Okay so it looks like there is no support for that mandatory flag. You are welcome to log a JIRA and work on a github PR http://camel.apache.org/contributing On Wed, Sep 27, 2017 at 8:37 PM, Juan Ignacio Barisich <juan.baris...@gmail.com> wrote: > Hi all > I am using the ProducerTemplate to send messages through RabbitMQ, with a > code like: > > ProducerTemplate camelProducer = ...; >> Object body = "a body"; >> Map<String, Object> headers = new HashMap<String, Object>(2); >> headers.put(RabbitMQConstants.DELIVERY_MODE, "2"); >> camelProducer.*sendBodyAndHeaders*(endpoint, body, headers); > > > That code works ok, but I need some way to set the mandatory flag in true, > to handle unroutable messages, as is said at > http://www.rabbitmq.com/api-guide.html#returning > > If I put a breakpoint at the basicPublish(*) methods > of com.rabbitmq.client.impl.ChannelN class, I can see that the camel > invocation comes from RabbitMQProducer, method basicPublish, line: > > channel.basicPublish(exchange, routingKey, properties, body); > > > That line does not specify the mandatory flag, so the RabbitMQ code uses > false as default: > > public void basicPublish(String exchange, String routingKey, >> BasicProperties props, byte[] body) throws IOException { >> basicPublish(exchange, routingKey, *false*, props, body); >> } > > > Do you know if there is a hack to set the mandatory flag in true, while > sending a message to RabbitMQ by using the ProducerTemplate ? BTW I am > using camel 2.15.3 > > Thanks in advance. > > Best regards, > Juan -- Claus Ibsen - http://davsclaus.com @davsclaus Camel in Action 2: https://www.manning.com/ibsen2
Mandatory flag when send a rabbitmq message using ProducerTemplate
Hi all I am using the ProducerTemplate to send messages through RabbitMQ, with a code like: ProducerTemplate camelProducer = ...; > Object body = "a body"; > Map<String, Object> headers = new HashMap<String, Object>(2); > headers.put(RabbitMQConstants.DELIVERY_MODE, "2"); > camelProducer.*sendBodyAndHeaders*(endpoint, body, headers); That code works ok, but I need some way to set the mandatory flag in true, to handle unroutable messages, as is said at http://www.rabbitmq.com/api-guide.html#returning If I put a breakpoint at the basicPublish(*) methods of com.rabbitmq.client.impl.ChannelN class, I can see that the camel invocation comes from RabbitMQProducer, method basicPublish, line: channel.basicPublish(exchange, routingKey, properties, body); That line does not specify the mandatory flag, so the RabbitMQ code uses false as default: public void basicPublish(String exchange, String routingKey, > BasicProperties props, byte[] body) throws IOException { > basicPublish(exchange, routingKey, *false*, props, body); > } Do you know if there is a hack to set the mandatory flag in true, while sending a message to RabbitMQ by using the ProducerTemplate ? BTW I am using camel 2.15.3 Thanks in advance. Best regards, Juan
Re: ProducerTemplate thread waits indefinitely
Could you please look into this issue and suggest possible solution __ If you reply to this email, your message will be added to the discussion below: http://camel.465427.n5.nabble.com/ProducerTemplate-thread-waits-indefinitely-tp5799224p5799351.html This email was sent by CamelJMSUser (via Nabble) To receive all replies by email, subscribe to this discussion: http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=subscribe_by_code=5799224=dXNlcnNAY2FtZWwuYXBhY2hlLm9yZ3w1Nzk5MjI0fC0xMjIzOTY3NDgw
ProducerTemplate thread waits indefinitely
I am using producerTemplate.asyncCallback(., ., .) method to publish messages to Tibco EMS. While running my application, if EMS server down then so-many threads as blocking and my server is creating lot of blocking threads then it moving to out of memory issue here is the connection code TibjmsConnectionFactory tibjmsConnectionFactory = new TibjmsConnectionFactory(); tibjmsConnectionFactory.setServerUrl(""); tibjmsConnectionFactory.setUserName(""); tibjmsConnectionFactory.setUserPassword(""); tibjmsConnectionFactory.setReconnAttemptCount(10); tibjmsConnectionFactory.setReconnAttemptDelay(1000); tibjmsConnectionFactory.setReconnAttemptTimeout(1000); tibjmsConnectionFactory.setConnAttemptTimeout(100); SingleConnectionFactory singleConnectionFactory = new SingleConnectionFactory(); singleConnectionFactory.setTargetConnectionFactory(tibjmsConnectionFactory); TibcoConnectionExceptionListener tibcoConnectionExceptionListener = new TibcoConnectionExceptionListener(); singleConnectionFactory.setExceptionListener(tibcoConnectionExceptionListener); singleConnectionFactory.setReconnectOnException(reconnectOnException); cacheConnectionFactory = new CachingConnectionFactory(); cacheConnectionFactory.setTargetConnectionFactory(singleConnectionFactory); cacheConnectionFactory.setSessionCacheSize(50); and here is the publisher code producerTemplate.asyncCallback(queueName, exchange,synchronization); And I attached thread dump, when Tibco EMS down, all producer thread are blocked and those are not releasing then will get OOM issue ThreadDump.xlsx <http://camel.465427.n5.nabble.com/file/n5799224/ThreadDump.xlsx> I am using camel-core/camel-spring/camel-jms 2.11.1 version. I saw in camel documentation issue with Camel API producer process() method. Please help me to resolve this issue Please help me to resolve the issue. -- View this message in context: http://camel.465427.n5.nabble.com/ProducerTemplate-thread-waits-indefinitely-tp5799224.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: ProducerTemplate thread waits indefinitely when messaging system (Tibco EMS) was down
Thanks for the information, I added all timeouts at my connection level. here is the connection code TibjmsConnectionFactory tibjmsConnectionFactory = new TibjmsConnectionFactory(); tibjmsConnectionFactory.setServerUrl(""); tibjmsConnectionFactory.setUserName(""); tibjmsConnectionFactory.setUserPassword(""); tibjmsConnectionFactory.setReconnAttemptCount(30); tibjmsConnectionFactory.setReconnAttemptDelay(1000); tibjmsConnectionFactory.setReconnAttemptTimeout(1000); tibjmsConnectionFactory.setConnAttemptTimeout(100); SingleConnectionFactory singleConnectionFactory = new SingleConnectionFactory(); singleConnectionFactory.setTargetConnectionFactory(tibjmsConnectionFactory); TibcoConnectionExceptionListener tibcoConnectionExceptionListener = new TibcoConnectionExceptionListener(); singleConnectionFactory.setExceptionListener(tibcoConnectionExceptionListener); singleConnectionFactory.setReconnectOnException(reconnectOnException); cacheConnectionFactory = new CachingConnectionFactory(); cacheConnectionFactory.setTargetConnectionFactory(singleConnectionFactory); cacheConnectionFactory.setSessionCacheSize(50); and here is the publisher code producerTemplate.asyncCallback(queueName, exchange,synchronization); And I attached thread dump, when Tibco EMS down, all producer thread are blocked and those are not releasing then will get OOM issue ThreadDump.xlsx <http://camel.465427.n5.nabble.com/file/n5799189/ThreadDump.xlsx> -- View this message in context: http://camel.465427.n5.nabble.com/ProducerTemplate-thread-waits-indefinitely-when-messaging-system-Tibco-EMS-was-down-tp5798479p5799189.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: ProducerTemplate thread waits indefinitely when messaging system (Tibco EMS) was down
You likely need to configure your jms client on tibco with some kind of timeout or fail fast or something. Look the the Tibco JMS documentation. On Fri, Apr 28, 2017 at 10:59 AM, prasad.dl <prasad@gmail.com> wrote: > I am using producerTemplate.asyncCallback(., ., .) method to publish messages > to Tibco EMS. While running my application, if EMS server down then so-many > producertemplate threads as waiting and my server is creating lot of > threads. > > Please help me to resolve the issue > > > > -- > View this message in context: > http://camel.465427.n5.nabble.com/ProducerTemplate-thread-waits-indefinitely-when-messaging-system-Tibco-EMS-was-down-tp5798479.html > Sent from the Camel - Users mailing list archive at Nabble.com. -- Claus Ibsen - http://davsclaus.com @davsclaus Camel in Action 2: https://www.manning.com/ibsen2
ProducerTemplate thread waits indefinitely when messaging system (Tibco EMS) was down
I am using producerTemplate.asyncCallback(., ., .) method to publish messages to Tibco EMS. While running my application, if EMS server down then so-many producertemplate threads as waiting and my server is creating lot of threads. Please help me to resolve the issue -- View this message in context: http://camel.465427.n5.nabble.com/ProducerTemplate-thread-waits-indefinitely-when-messaging-system-Tibco-EMS-was-down-tp5798479.html Sent from the Camel - Users mailing list archive at Nabble.com.
RE: ProducerTemplate using netty4 component
To add some amplifying information, this behavior only shows up when using a ProducerTemplate. If I use the netty4 component to a ".to()" Endpoint everything works as expected. * I am not sure if its spring related, I used netty with tcp with the java dsl on 2.17 and that works. You could log an issue as it is perhaps a bug? On Thu, Jan 26, 2017 at 3:32 PM, Giordano, Michael [via Camel] < ml-node+s465427n5793087...@n5.nabble.com> wrote: > Yes except the error message changes to > > Failed to resolve endpoint: tcp://10.18.2.161:6509 due to: No > component found with scheme: tcp > > -Original Message- > From: souciance [mailto:[hidden email] > <http:///user/SendEmail.jtp?type=node=5793087=0>] > Sent: Thursday, January 26, 2017 6:24 AM > To: [hidden email] > <http:///user/SendEmail.jtp?type=node=5793087=1> > Subject: Re: ProducerTemplate using netty4 component > > Hmm strange, do you get the same error if you switch from udp to tcp > just for the sake of it? > > On Wed, Jan 25, 2017 at 11:20 PM, Giordano, Michael [via Camel] < > [hidden email] > <http:///user/SendEmail.jtp?type=node=5793087=2>> > wrote: > > > I am running into an issue when I use the netty4 component with a > > ProducerTemplate. > > > > Processor bean : > > > > @EndpointInject(uri="netty4:udp://10.18.2.161:6509") > > private ProducerTemplate producerTemplate; > > > > When Spring Boot tries to create the bean, I get this error message : > > > > Failed to resolve endpoint: udp://10.18.2.161:6509 due to: No > > component found with scheme: udp > > > > (Full stacktrace below) > > > > Error reproduced with > > Spring Boot versions : 1.3.8-RELEASE, 1.4.3-RELEASE Camel versions : > > 2.17.5, 2.18.1 > > > > As part of my debugging efforts, I found this curious line : > > > > 2017-01-25 13:31:16,905 DEBUG [main] > > org.apache.camel.spring.SpringCamelContext > > netty4://udp://10.18.2.161:6509 converted to endpoint: > > Endpoint[udp:// 10.18.2.161:6509] by component: org.apache.camel.component. > > netty4.NettyComponent@5807efad > > > > Has anyone else encountered this issue? Am I doing something wrong? > > > > Thanks, > > Mike G. > > > > Full Stacktrace : > > > > 2017-01-25 17:16:59,423 ERROR [main] > > org.springframework.boot.SpringApplication > > Application startup failed > > org.apache.camel.spring.boot.CamelSpringBootInitializationException: > > org.apache.camel.ResolveEndpointFailedException: Failed to resolve > > endpoint: udp://10.18.2.161:6509 due to: No component found with > scheme: > > udp > > at org.apache.camel.spring.boot.RoutesCollector. > > onApplicationEvent(RoutesCollector.java:124) > > at org.apache.camel.spring.boot.RoutesCollector. > > onApplicationEvent(RoutesCollector.java:41) > > at org.springframework.context.event. > > SimpleApplicationEventMulticaster.invokeListener( > > SimpleApplicationEventMulticaster.java:166) > > at org.springframework.context.event. > > SimpleApplicationEventMulticaster.multicastEvent( > > SimpleApplicationEventMulticaster.java:138) > > at org.springframework.context.support.AbstractApplicationContext. > > > publishEvent(AbstractApplicationContext.java:383) > > at org.springframework.context.support.AbstractApplicationContext. > > > publishEvent(AbstractApplicationContext.java:337) > > at org.springframework.context.support.AbstractApplicationContext. > > > finishRefresh(AbstractApplicationContext.java:882) > > at org.springframework.boot.context.embedded. > > EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationCo > > nt > > ext.java:144) > > > > at org.springframework.context.support.AbstractApplicationContext. > > > refresh(AbstractApplicationContext.java:545) > > at org.springframework.boot.context.embedded. > > EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext. > > ja > > va:122) > > > > at > > org.springframework.boot.SpringApplication.refresh(SpringApplication > > .j > > ava:761) > > > > at > > org.springframework.boot.SpringApplication.refreshContext(SpringAppl > > ic > > ation.java:371) > > > > at > > org.springframework.boot.SpringApplication.run(SpringApplication.java: > > 315) > > > > at > > org.springframework.boot
Re: ProducerTemplate using netty4 component
I am not sure if its spring related, I used netty with tcp with the java dsl on 2.17 and that works. You could log an issue as it is perhaps a bug? On Thu, Jan 26, 2017 at 3:32 PM, Giordano, Michael [via Camel] < ml-node+s465427n5793087...@n5.nabble.com> wrote: > Yes except the error message changes to > > Failed to resolve endpoint: tcp://10.18.2.161:6509 due to: No component > found with scheme: tcp > > -Original Message- > From: souciance [mailto:[hidden email] > <http:///user/SendEmail.jtp?type=node=5793087=0>] > Sent: Thursday, January 26, 2017 6:24 AM > To: [hidden email] <http:///user/SendEmail.jtp?type=node=5793087=1> > Subject: Re: ProducerTemplate using netty4 component > > Hmm strange, do you get the same error if you switch from udp to tcp just > for the sake of it? > > On Wed, Jan 25, 2017 at 11:20 PM, Giordano, Michael [via Camel] < > [hidden email] <http:///user/SendEmail.jtp?type=node=5793087=2>> > wrote: > > > I am running into an issue when I use the netty4 component with a > > ProducerTemplate. > > > > Processor bean : > > > > @EndpointInject(uri="netty4:udp://10.18.2.161:6509") > > private ProducerTemplate producerTemplate; > > > > When Spring Boot tries to create the bean, I get this error message : > > > > Failed to resolve endpoint: udp://10.18.2.161:6509 due to: No > > component found with scheme: udp > > > > (Full stacktrace below) > > > > Error reproduced with > > Spring Boot versions : 1.3.8-RELEASE, 1.4.3-RELEASE Camel versions : > > 2.17.5, 2.18.1 > > > > As part of my debugging efforts, I found this curious line : > > > > 2017-01-25 13:31:16,905 DEBUG [main] > > org.apache.camel.spring.SpringCamelContext > > netty4://udp://10.18.2.161:6509 converted to endpoint: Endpoint[udp:// > > 10.18.2.161:6509] by component: org.apache.camel.component. > > netty4.NettyComponent@5807efad > > > > Has anyone else encountered this issue? Am I doing something wrong? > > > > Thanks, > > Mike G. > > > > Full Stacktrace : > > > > 2017-01-25 17:16:59,423 ERROR [main] > > org.springframework.boot.SpringApplication > > Application startup failed > > org.apache.camel.spring.boot.CamelSpringBootInitializationException: > > org.apache.camel.ResolveEndpointFailedException: Failed to resolve > > endpoint: udp://10.18.2.161:6509 due to: No component found with > scheme: > > udp > > at org.apache.camel.spring.boot.RoutesCollector. > > onApplicationEvent(RoutesCollector.java:124) > > at org.apache.camel.spring.boot.RoutesCollector. > > onApplicationEvent(RoutesCollector.java:41) > > at org.springframework.context.event. > > SimpleApplicationEventMulticaster.invokeListener( > > SimpleApplicationEventMulticaster.java:166) > > at org.springframework.context.event. > > SimpleApplicationEventMulticaster.multicastEvent( > > SimpleApplicationEventMulticaster.java:138) > > at org.springframework.context.support.AbstractApplicationContext. > > > publishEvent(AbstractApplicationContext.java:383) > > at org.springframework.context.support.AbstractApplicationContext. > > > publishEvent(AbstractApplicationContext.java:337) > > at org.springframework.context.support.AbstractApplicationContext. > > > finishRefresh(AbstractApplicationContext.java:882) > > at org.springframework.boot.context.embedded. > > EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationCont > > ext.java:144) > > > > at org.springframework.context.support.AbstractApplicationContext. > > > refresh(AbstractApplicationContext.java:545) > > at org.springframework.boot.context.embedded. > > EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.ja > > va:122) > > > > at > > org.springframework.boot.SpringApplication.refresh(SpringApplication.j > > ava:761) > > > > at > > org.springframework.boot.SpringApplication.refreshContext(SpringApplic > > ation.java:371) > > > > at > > org.springframework.boot.SpringApplication.run(SpringApplication.java: > > 315) > > > > at > > org.springframework.boot.SpringApplication.run(SpringApplication.java: > > 1186) > > > > at > > org.springframework.boot.SpringApplication.run(SpringApplication.java: > > 1175) > > > > at com.vistronix.mmai.pcap.Application.main(Application.java:9) > > at sun.reflect.NativeMetho
RE: ProducerTemplate using netty4 component
Yes except the error message changes to Failed to resolve endpoint: tcp://10.18.2.161:6509 due to: No component found with scheme: tcp -Original Message- From: souciance [mailto:souciance.eqdam.ras...@gmail.com] Sent: Thursday, January 26, 2017 6:24 AM To: users@camel.apache.org Subject: Re: ProducerTemplate using netty4 component Hmm strange, do you get the same error if you switch from udp to tcp just for the sake of it? On Wed, Jan 25, 2017 at 11:20 PM, Giordano, Michael [via Camel] < ml-node+s465427n5793064...@n5.nabble.com> wrote: > I am running into an issue when I use the netty4 component with a > ProducerTemplate. > > Processor bean : > > @EndpointInject(uri="netty4:udp://10.18.2.161:6509") > private ProducerTemplate producerTemplate; > > When Spring Boot tries to create the bean, I get this error message : > > Failed to resolve endpoint: udp://10.18.2.161:6509 due to: No > component found with scheme: udp > > (Full stacktrace below) > > Error reproduced with > Spring Boot versions : 1.3.8-RELEASE, 1.4.3-RELEASE Camel versions : > 2.17.5, 2.18.1 > > As part of my debugging efforts, I found this curious line : > > 2017-01-25 13:31:16,905 DEBUG [main] > org.apache.camel.spring.SpringCamelContext > netty4://udp://10.18.2.161:6509 converted to endpoint: Endpoint[udp:// > 10.18.2.161:6509] by component: org.apache.camel.component. > netty4.NettyComponent@5807efad > > Has anyone else encountered this issue? Am I doing something wrong? > > Thanks, > Mike G. > > Full Stacktrace : > > 2017-01-25 17:16:59,423 ERROR [main] > org.springframework.boot.SpringApplication > Application startup failed > org.apache.camel.spring.boot.CamelSpringBootInitializationException: > org.apache.camel.ResolveEndpointFailedException: Failed to resolve > endpoint: udp://10.18.2.161:6509 due to: No component found with scheme: > udp > at org.apache.camel.spring.boot.RoutesCollector. > onApplicationEvent(RoutesCollector.java:124) > at org.apache.camel.spring.boot.RoutesCollector. > onApplicationEvent(RoutesCollector.java:41) > at org.springframework.context.event. > SimpleApplicationEventMulticaster.invokeListener( > SimpleApplicationEventMulticaster.java:166) > at org.springframework.context.event. > SimpleApplicationEventMulticaster.multicastEvent( > SimpleApplicationEventMulticaster.java:138) > at org.springframework.context.support.AbstractApplicationContext. > publishEvent(AbstractApplicationContext.java:383) > at org.springframework.context.support.AbstractApplicationContext. > publishEvent(AbstractApplicationContext.java:337) > at org.springframework.context.support.AbstractApplicationContext. > finishRefresh(AbstractApplicationContext.java:882) > at org.springframework.boot.context.embedded. > EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationCont > ext.java:144) > > at org.springframework.context.support.AbstractApplicationContext. > refresh(AbstractApplicationContext.java:545) > at org.springframework.boot.context.embedded. > EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.ja > va:122) > > at > org.springframework.boot.SpringApplication.refresh(SpringApplication.j > ava:761) > > at > org.springframework.boot.SpringApplication.refreshContext(SpringApplic > ation.java:371) > > at > org.springframework.boot.SpringApplication.run(SpringApplication.java: > 315) > > at > org.springframework.boot.SpringApplication.run(SpringApplication.java: > 1186) > > at > org.springframework.boot.SpringApplication.run(SpringApplication.java: > 1175) > > at com.vistronix.mmai.pcap.Application.main(Application.java:9) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) > at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown > Source) > at java.lang.reflect.Method.invoke(Unknown Source) > at > org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner. > java:48) > > at > org.springframework.boot.loader.Launcher.launch(Launcher.java:87) > > at > org.springframework.boot.loader.Launcher.launch(Launcher.java:50) > > at > org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) > > Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to > resolve endpoint: udp://10.18.2.161:6509 due to: No component found > with > scheme: udp > at > org.apache.came
Re: ProducerTemplate using netty4 component
Hmm strange, do you get the same error if you switch from udp to tcp just for the sake of it? On Wed, Jan 25, 2017 at 11:20 PM, Giordano, Michael [via Camel] < ml-node+s465427n5793064...@n5.nabble.com> wrote: > I am running into an issue when I use the netty4 component with a > ProducerTemplate. > > Processor bean : > > @EndpointInject(uri="netty4:udp://10.18.2.161:6509") > private ProducerTemplate producerTemplate; > > When Spring Boot tries to create the bean, I get this error message : > > Failed to resolve endpoint: udp://10.18.2.161:6509 due to: No component > found with scheme: udp > > (Full stacktrace below) > > Error reproduced with > Spring Boot versions : 1.3.8-RELEASE, 1.4.3-RELEASE > Camel versions : 2.17.5, 2.18.1 > > As part of my debugging efforts, I found this curious line : > > 2017-01-25 13:31:16,905 DEBUG [main] > org.apache.camel.spring.SpringCamelContext > netty4://udp://10.18.2.161:6509 converted to endpoint: Endpoint[udp:// > 10.18.2.161:6509] by component: org.apache.camel.component. > netty4.NettyComponent@5807efad > > Has anyone else encountered this issue? Am I doing something wrong? > > Thanks, > Mike G. > > Full Stacktrace : > > 2017-01-25 17:16:59,423 ERROR [main] > org.springframework.boot.SpringApplication > Application startup failed > org.apache.camel.spring.boot.CamelSpringBootInitializationException: > org.apache.camel.ResolveEndpointFailedException: Failed to resolve > endpoint: udp://10.18.2.161:6509 due to: No component found with scheme: > udp > at org.apache.camel.spring.boot.RoutesCollector. > onApplicationEvent(RoutesCollector.java:124) > at org.apache.camel.spring.boot.RoutesCollector. > onApplicationEvent(RoutesCollector.java:41) > at org.springframework.context.event. > SimpleApplicationEventMulticaster.invokeListener( > SimpleApplicationEventMulticaster.java:166) > at org.springframework.context.event. > SimpleApplicationEventMulticaster.multicastEvent( > SimpleApplicationEventMulticaster.java:138) > at org.springframework.context.support.AbstractApplicationContext. > publishEvent(AbstractApplicationContext.java:383) > at org.springframework.context.support.AbstractApplicationContext. > publishEvent(AbstractApplicationContext.java:337) > at org.springframework.context.support.AbstractApplicationContext. > finishRefresh(AbstractApplicationContext.java:882) > at org.springframework.boot.context.embedded. > EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:144) > > at org.springframework.context.support.AbstractApplicationContext. > refresh(AbstractApplicationContext.java:545) > at org.springframework.boot.context.embedded. > EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) > > at > org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761) > > at > org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:371) > > at > org.springframework.boot.SpringApplication.run(SpringApplication.java:315) > > at > org.springframework.boot.SpringApplication.run(SpringApplication.java:1186) > > at > org.springframework.boot.SpringApplication.run(SpringApplication.java:1175) > > at com.vistronix.mmai.pcap.Application.main(Application.java:9) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) > at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown > Source) > at java.lang.reflect.Method.invoke(Unknown Source) > at > org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) > > at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) > > at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) > > at > org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) > > Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to > resolve endpoint: udp://10.18.2.161:6509 due to: No component found with > scheme: udp > at > org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:628) > > at org.apache.camel.impl.DefaultProducerTemplate.doStart( > DefaultProducerTemplate.java:731) > at > org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61) > > at > org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:75) > > at org.apache.camel.impl.DeferServiceStartupListener. > onCamelContextStarted(Defer
ProducerTemplate using netty4 component
I am running into an issue when I use the netty4 component with a ProducerTemplate. Processor bean : @EndpointInject(uri="netty4:udp://10.18.2.161:6509") private ProducerTemplate producerTemplate; When Spring Boot tries to create the bean, I get this error message : Failed to resolve endpoint: udp://10.18.2.161:6509 due to: No component found with scheme: udp (Full stacktrace below) Error reproduced with Spring Boot versions : 1.3.8-RELEASE, 1.4.3-RELEASE Camel versions : 2.17.5, 2.18.1 As part of my debugging efforts, I found this curious line : 2017-01-25 13:31:16,905 DEBUG [main] org.apache.camel.spring.SpringCamelContext netty4://udp://10.18.2.161:6509 converted to endpoint: Endpoint[udp://10.18.2.161:6509] by component: org.apache.camel.component.netty4.NettyComponent@5807efad Has anyone else encountered this issue? Am I doing something wrong? Thanks, Mike G. Full Stacktrace : 2017-01-25 17:16:59,423 ERROR [main] org.springframework.boot.SpringApplication Application startup failed org.apache.camel.spring.boot.CamelSpringBootInitializationException: org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: udp://10.18.2.161:6509 due to: No component found with scheme: udp at org.apache.camel.spring.boot.RoutesCollector.onApplicationEvent(RoutesCollector.java:124) at org.apache.camel.spring.boot.RoutesCollector.onApplicationEvent(RoutesCollector.java:41) at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:166) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:138) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:383) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:337) at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:882) at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:144) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:545) at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:371) at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1186) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1175) at com.vistronix.mmai.pcap.Application.main(Application.java:9) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: udp://10.18.2.161:6509 due to: No component found with scheme: udp at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:628) at org.apache.camel.impl.DefaultProducerTemplate.doStart(DefaultProducerTemplate.java:731) at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61) at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:75) at org.apache.camel.impl.DeferServiceStartupListener.onCamelContextStarted(DeferServiceStartupListener.java:49) at org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(DefaultCamelContext.java:3529) at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRoutes(DefaultCamelContext.java:3308) at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:3162) at org.apache.camel.impl.DefaultCamelContext.access$000(DefaultCamelContext.java:182) at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2957) at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2953) at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext
camel:java.lang.IllegalStateException: ProducerTemplate has not been started
2017-01-11 22:26:20,224 [ievJmsContainer-2][][][][][][][] WARN org.springframework.jms.listener.DefaultMessageListenerContainer - Execution of JMS message listener failed, and no ErrorHandler has been set. java.lang.IllegalStateException: ProducerTemplate has not been started at org.apache.camel.impl.DefaultProducerTemplate.getProducerCache(DefaultProducerTemplate.java:689) at org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:144) at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:161) at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:370) at com.service.sample.subscriber.SubscriberMessageListener.onMessage(SubscriberMessageListener.java:37) at sun.reflect.GeneratedMethodAccessor120.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:73) at com.edb.finance.common.spring.aop.monitoring.ExtendedMonitoringSpringInterceptor.invoke(ExtendedMonitoringSpringInterceptor.java:120) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:73) at com.edb.finance.common.spring.aop.monitoring.ExtendedMonitoringSpringInterceptor.invoke(ExtendedMonitoringSpringInterceptor.java:120) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208) at com.sun.proxy.$Proxy193.onMessage(Unknown Source) at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:746) at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:684) at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:651) at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:315) at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:233) at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1158) at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1150) at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:1047) at java.lang.Thread.run(Thread.java:745) - Thanks Jaganmohan Paspula -- View this message in context: http://camel.465427.n5.nabble.com/camel-java-lang-IllegalStateException-ProducerTemplate-has-not-been-started-tp5792478.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: ProducerTemplate creates too much threads
It's extremely important to learn the EIPs available to you in Camel and leverage them to the greatest extent possible. They'll do a lot of the heavy lifting. You can use a CBR to send data to various routes or beans based on some value in the data header or body, for example. I handle SOAP requests all the time without using Processors. As an example of how this is easily accomplished look at this snippet of blueprint. It could be done in others as well. direct-vm:${header.operationName} The operation name there is set on the method of the SOAP interface or in the WSDL (though I usually go code first.) If you set up routes that are based on the operation name listening on that then they will receive the message. So here's a definition of an API and I've decorated it for use in both the SOAP and REST endpoints. (The REST endpoints/uris in @Path are named incorrectly here as they should be noun based but it gets the idea across.) @WebMethod(operationName = "getFoo", action = "") @GET @Path("/resource/bar/{token}") @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_JSON}) public String getFoo(@WebParam Foo foo); @WebMethod(operationName = "addFoo", action = "") @PUT @Path("/resource/foo/{token}") @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_JSON}) public void addFoo(@WebParam Foo foo); So we have this in our SOAP and REST related camel contexts/routes. direct-vm:${header.operationName} http://camel.apache.org/schema/blueprint;> ${body[0]} direct-vm:${header.operationName} In the same or different bundle you can then add: Now whether the request is coming in through SOAP or REST it is will invoke the addFoo route, unmarshal the object into a Foo object, and send it to the route. No need to use Processors, ProducerTemplates or anything else. Just let Camel do the work for you and learn the EIPs! On Sun, Sep 11, 2016 at 12:19 AM, niteshjain <niteshjain...@gmail.com> wrote: > I'm using Processor interface, to handle the incoming SOAP request from the > Exchange and apply some business logic on it, Based on the business logic I > wanted to invoke different camel routes (defined in camel context xml), > hence ProducerTemplate to invoke different camel routes. > > Regards, > Nithesh > > > > -- > View this message in context: http://camel.465427.n5.nabble. > com/ProducerTemplate-creates-too-much-threads-tp5751299p5787445.html > Sent from the Camel - Users mailing list archive at Nabble.com. >
Re: ProducerTemplate creates too much threads
I'm using Processor interface, to handle the incoming SOAP request from the Exchange and apply some business logic on it, Based on the business logic I wanted to invoke different camel routes (defined in camel context xml), hence ProducerTemplate to invoke different camel routes. Regards, Nithesh -- View this message in context: http://camel.465427.n5.nabble.com/ProducerTemplate-creates-too-much-threads-tp5751299p5787445.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: ProducerTemplate creates too much threads
Normally you don't want to shut it down until the application is shutting down. And then it should happen of its own accord. Another question is why are you using the Processor interface? Unless there's a compelling reason just use a regular old Java bean. In a lot of these cases you don't even need a producer template. Just let Camel do the work. One of the biggest mistakes I see when folks start using Camel is they'll get some input and then write an application inside a Processor. Camel will us reflection on your bean to figure out which method to invoke. It will invoked the method using the body in the Exchange so you don't have to fool with it. You can explicitly invoke a method on a bean if necessary (when there are two methods that take the same datatype for example) because in that case Camel has no way of differentiating which method you'd like to invoke. In a number of those cases I'll just split my handler in two and use each in its rightful place. So if your payload is MyPayloadBean, the a MyPayloadHandler might look like this: public class MyPayloadHandler { public MyPaylaodBean handle(MyPayloadBean payload) { //Do something withe payload here and then just return it so Camel can route it to the next place. return payload; //In reality I don't believe you even have to return the payload if all you are doing is mutating data on it. It will continue being used but if you instantiate or create a new one or a different type then you'll want to specify the return. I do // it anyway just to make it clear as to what is happening there so if someone else or even I have to come back later and change it is obvious as to what is happening. } I rarely if ever use Processors and the only time I'd really think about it is if I had to muck about with headers. Even then I'd prefer to do it from the Camel route if I can (and 90% of the time I can). Or if I just need access to the information they contain and don't need to mutate it I'll add another parameter to the method and then add @Header to tell Camel what it is I want. http://camel.apache.org/bean-binding.html There's a very important point to note about all this. Notice that your MyPayloadHandler is not dependent on the Camel framework mechanisms. It is decoupled and is totally portable. It also means that you can use Plain ol' JUnit to test the MyPayloadHandler because it is just a POJO. In the case where you are invoking a ProducerTemplate there ins't anything particularly wrong or bad about it but ask yourself if you couldn't just add a .to(). In your case, I don't know what comes before the Processor but let's say it is a file or direct or seda or whatever. from("direct:foo").(MyPayloadHandler.class).to("direct:invokeWS"); --You can also separately instantiate the payload handler or just instantiate it and reference it by a name. Notice how you are letting Camel do its job here and aren't manually having to manipulate anything. Are there times to use Producer or Consumer templates? Sure, but make sure you really need them and can't just wire in a camel route to send it on. And really think hard if you need to a use a Processor and can't figure out another less messy way of going about it. If you don't have a compelling reason to use the Processor then just use Pojo. If you don't have a compelling reason to use the ProducerTemplate, then just use the routes. If you look in the Camel in Action book you'll see a section in there where Clause talks about the difference in using bean binding versus Processor. If I had my beat up old copy around I'd tell you what page to look on. Unfortunately so much of the online documentation shows processors being use that that sort of gets lost. I assume that much of that is due to its having been written earlier before the bean binding became robust. If I could find my beat up old copy around here I'd tell you exactly where to look but I'm not sure where it's at. I've been waiting to throw money at Claus when the new copy comes out or even review it while it is in edit. Santa Claus has promised sometime around Christmas or so. I hope so because my children have already put it on their lists. Brad On Sat, Sep 10, 2016 at 1:24 AM, niteshjain <niteshjain...@gmail.com> wrote: > Thanks for your valuable response, > > Now I'm using ProducerTemplate to invoke a camel route by injecting the > template as below: > > public class Test implements Processor { > @EndpointInject(uri="direct:invokeWS") > ProducerTemplate producer; > >@Override > public void process(Exchange exchange) throws Exception { > . > . >producer.requestBody(somePayload); //invokes the camel route > "direct:invokeWS" as expected. > . > . > } > } > > and It's working fine, my doubt is when do i call *producer.stop() method* > to cl
Re: ProducerTemplate creates too much threads
Thanks for your valuable response, Now I'm using ProducerTemplate to invoke a camel route by injecting the template as below: public class Test implements Processor { @EndpointInject(uri="direct:invokeWS") ProducerTemplate producer; @Override public void process(Exchange exchange) throws Exception { . . producer.requestBody(somePayload); //invokes the camel route "direct:invokeWS" as expected. . . } } and It's working fine, my doubt is when do i call *producer.stop() method* to close down all the resources it has been using ? as my application will be running forever ! and for each SOAP request process() method of Test class will be invoked. Thanks, Nithesh -- View this message in context: http://camel.465427.n5.nabble.com/ProducerTemplate-creates-too-much-threads-tp5751299p5787436.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: ProducerTemplate creates too much threads
OK, but that doesn't apply to an inject ProducerTemplate in a bean, only to ones created on the incoming thread. If you have something like. It is an *instance *variable. It is not created on the incoming thread but is only created at start up time. public class FooHandler { @EndpointInject(uri="activemq:foo.bar") ProducerTemplate producer; public void doSomething() { if (whatever) { producer.sendBody("world!"); } } http://camel.apache.org/pojo-producing.html Make sure you look at what they are conveying. This not suggesting that you create a singleton and serve up ProducerTemplates from it. It is saying you shouldn't create them inside the invocation (on the incoming thread). Specifically it says: *You are not meant to create a ProducerTemplate for each message invocation; you are meant to create a single instance on startup and keep it around.* http://camel.apache.org/why-does-camel-use-too-many-threads-with-producertemplate.html On Thu, Sep 8, 2016 at 10:50 PM, niteshjain <niteshjain...@gmail.com> wrote: > Hi, > > Can you please look into this query: > http://camel.465427.n5.nabble.com/Should-i-start-stop- > producer-templates-often-td5787400.html > > any help is appreciated. > > Thanks, > Nithesh > > > > -- > View this message in context: http://camel.465427.n5.nabble. > com/ProducerTemplate-creates-too-much-threads-tp5751299p5787401.html > Sent from the Camel - Users mailing list archive at Nabble.com. >
Re: ProducerTemplate creates too much threads
Hi, Can you please look into this query: http://camel.465427.n5.nabble.com/Should-i-start-stop-producer-templates-often-td5787400.html any help is appreciated. Thanks, Nithesh -- View this message in context: http://camel.465427.n5.nabble.com/ProducerTemplate-creates-too-much-threads-tp5751299p5787401.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: when to call start() and stop() on ProducerTemplate?
Yes that is fine to only call stop on server shutdown. Then you can reuse the same producer template. Only if you do not use the template anymore you can call stop before. On Wed, Aug 31, 2016 at 8:33 AM, atluris <atluri.fo...@gmail.com> wrote: > Hi, > > Based on below article, we are creating single producer template instance > and using it as and when needed to execute the camel route explicitly. > > http://camel.apache.org/why-does-camel-use-too-many-threads-with-producertemplate.html > > We are calling start() during server startup and stop() during shutdown. Is > that fine, or do we need to call start() and stop() during each message > invocation? > > Thanks & Regards, > Srinivas Atluri. > > > > -- > View this message in context: > http://camel.465427.n5.nabble.com/when-to-call-start-and-stop-on-ProducerTemplate-tp5787020.html > Sent from the Camel - Users mailing list archive at Nabble.com. -- Claus Ibsen - http://davsclaus.com @davsclaus Camel in Action 2: https://www.manning.com/ibsen2
when to call start() and stop() on ProducerTemplate?
Hi, Based on below article, we are creating single producer template instance and using it as and when needed to execute the camel route explicitly. http://camel.apache.org/why-does-camel-use-too-many-threads-with-producertemplate.html We are calling start() during server startup and stop() during shutdown. Is that fine, or do we need to call start() and stop() during each message invocation? Thanks & Regards, Srinivas Atluri. -- View this message in context: http://camel.465427.n5.nabble.com/when-to-call-start-and-stop-on-ProducerTemplate-tp5787020.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: @Produce vs @ProducerTemplate
Reading through the proxy description I suspect the reason it was working in one instance and not in the other is the one that worked with public String foo(String bar) and that was automatically getting bound correctly. The other method had a bean class and a void return and it was not getting bound. Instead the invocation proxy was getting sent over and then when it was getting put through the recipientList to the velocity macro to render an error email the toString was not being called on the body inside the inocation handler but on the invocation handler itself. It sounds like much of that is going to be a non-issue after 2.16. It's also going to be less of an issue because I'll likely use more simple wrapper classes and I'm OK with those using ProducerTemplate. Previously the issue with those was having to create multiple levels of XML injection to get that together and then testing it. The CDI makes that a non-issue really since it simply looks for what needs to be injected. So here's a wrapper class for the email notification. I inject this object into other handlers, validators, etc. to fire off detected problems. @Inject @Uri(SEND_EMAIL_ERROR_NOTICE) private ProducerTemplate emailErrorRoute; public void notifyMalformedFileName(String fileName){ emailErrorRoute.sendBodyAndHeaders(fileName, createMalformedFileEmailHeaders()); } The createMalformedFileEmailHeaders is a static method that returns a map with to/from/subject and so on. Theoretically I could have an interface that's the same as my wrapper class and use that instead of the ProducerTemplate with the @Produce. I'll have to think about the implications of it as I'm not sure if it buys me much. On Thu, Aug 11, 2016 at 10:14 AM, Brad Johnson <brad.john...@mediadriver.com > wrote: > I'm using 2.15.x in Fuse 6.2 and experimenting with Camel 2.17 and CDI in > Fuse 6.3 which I downloaded. But I don't really need the Fuse container > for the testing with the CDI test runner. > > I really like the way this is all going. > > Brad > > On Thu, Aug 11, 2016 at 8:32 AM, Claus Ibsen <claus.ib...@gmail.com> > wrote: > >> What version of Camel are you using? >> >> From Camel 2.16 onwards @Produce / proxy should use bean parameter >> binding by default >> http://camel.apache.org/using-camelproxy.html >> >> On Mon, Aug 8, 2016 at 4:02 PM, Brad Johnson >> <brad.john...@mediadriver.com> wrote: >> > I use producer template quite a bit and it works well but it obviously >> is a >> > bit more coupled to the Camel API than using the @Produce with an >> interface. >> > >> > The problem is I can't tell exactly when @Produce is going to work as I >> > expect it to. Currently I have two routes, for example, one that makes >> a >> > call to a direct route to do a look up and return a field during >> > processing. It works fine. >> > >> > A second route that I have is similar but it sends a String fileName to >> a >> > an error route to send and email via a velocity template. If I use the >> > ProducerTemplate that works fine. If I use the @Produce what I end up >> with >> > is the body rendered showing the BeanInvocation proxy itself with the >> > actual body to be rendered contained with in it. >> > >> > I ran into this before in an different situation and ended up removing >> the >> > @Produce although I was actually able to cause it to work correctly by >> an >> > indirect bean call on it which seems to have cause the proxy to divulge >> its >> > contents. >> > >> > In this particular case I'm invoking the interface which sends it to a >> > second route that sets other information like to/from/subject and then >> uses >> > a recipientList to invoke the velocity template I've specified for that >> > particular error message. >> > >> > Brad >> >> >> >> -- >> Claus Ibsen >> - >> http://davsclaus.com @davsclaus >> Camel in Action 2: https://www.manning.com/ibsen2 >> > >
Re: @Produce vs @ProducerTemplate
I'm using 2.15.x in Fuse 6.2 and experimenting with Camel 2.17 and CDI in Fuse 6.3 which I downloaded. But I don't really need the Fuse container for the testing with the CDI test runner. I really like the way this is all going. Brad On Thu, Aug 11, 2016 at 8:32 AM, Claus Ibsen <claus.ib...@gmail.com> wrote: > What version of Camel are you using? > > From Camel 2.16 onwards @Produce / proxy should use bean parameter > binding by default > http://camel.apache.org/using-camelproxy.html > > On Mon, Aug 8, 2016 at 4:02 PM, Brad Johnson > <brad.john...@mediadriver.com> wrote: > > I use producer template quite a bit and it works well but it obviously > is a > > bit more coupled to the Camel API than using the @Produce with an > interface. > > > > The problem is I can't tell exactly when @Produce is going to work as I > > expect it to. Currently I have two routes, for example, one that makes a > > call to a direct route to do a look up and return a field during > > processing. It works fine. > > > > A second route that I have is similar but it sends a String fileName to a > > an error route to send and email via a velocity template. If I use the > > ProducerTemplate that works fine. If I use the @Produce what I end up > with > > is the body rendered showing the BeanInvocation proxy itself with the > > actual body to be rendered contained with in it. > > > > I ran into this before in an different situation and ended up removing > the > > @Produce although I was actually able to cause it to work correctly by an > > indirect bean call on it which seems to have cause the proxy to divulge > its > > contents. > > > > In this particular case I'm invoking the interface which sends it to a > > second route that sets other information like to/from/subject and then > uses > > a recipientList to invoke the velocity template I've specified for that > > particular error message. > > > > Brad > > > > -- > Claus Ibsen > - > http://davsclaus.com @davsclaus > Camel in Action 2: https://www.manning.com/ibsen2 >
Re: @Produce vs @ProducerTemplate
What version of Camel are you using? >From Camel 2.16 onwards @Produce / proxy should use bean parameter binding by default http://camel.apache.org/using-camelproxy.html On Mon, Aug 8, 2016 at 4:02 PM, Brad Johnson <brad.john...@mediadriver.com> wrote: > I use producer template quite a bit and it works well but it obviously is a > bit more coupled to the Camel API than using the @Produce with an interface. > > The problem is I can't tell exactly when @Produce is going to work as I > expect it to. Currently I have two routes, for example, one that makes a > call to a direct route to do a look up and return a field during > processing. It works fine. > > A second route that I have is similar but it sends a String fileName to a > an error route to send and email via a velocity template. If I use the > ProducerTemplate that works fine. If I use the @Produce what I end up with > is the body rendered showing the BeanInvocation proxy itself with the > actual body to be rendered contained with in it. > > I ran into this before in an different situation and ended up removing the > @Produce although I was actually able to cause it to work correctly by an > indirect bean call on it which seems to have cause the proxy to divulge its > contents. > > In this particular case I'm invoking the interface which sends it to a > second route that sets other information like to/from/subject and then uses > a recipientList to invoke the velocity template I've specified for that > particular error message. > > Brad -- Claus Ibsen - http://davsclaus.com @davsclaus Camel in Action 2: https://www.manning.com/ibsen2
Re: @Produce vs @ProducerTemplate
Ugh, early Monday...That should be @EndpointInject of ProducerTemplate and not @ProducerTemplate. On Mon, Aug 8, 2016 at 9:02 AM, Brad Johnson <brad.john...@mediadriver.com> wrote: > I use producer template quite a bit and it works well but it obviously is > a bit more coupled to the Camel API than using the @Produce with an > interface. > > The problem is I can't tell exactly when @Produce is going to work as I > expect it to. Currently I have two routes, for example, one that makes a > call to a direct route to do a look up and return a field during > processing. It works fine. > > A second route that I have is similar but it sends a String fileName to a > an error route to send and email via a velocity template. If I use the > ProducerTemplate that works fine. If I use the @Produce what I end up with > is the body rendered showing the BeanInvocation proxy itself with the > actual body to be rendered contained with in it. > > I ran into this before in an different situation and ended up removing the > @Produce although I was actually able to cause it to work correctly by an > indirect bean call on it which seems to have cause the proxy to divulge its > contents. > > In this particular case I'm invoking the interface which sends it to a > second route that sets other information like to/from/subject and then uses > a recipientList to invoke the velocity template I've specified for that > particular error message. > > Brad > > >
@Produce vs @ProducerTemplate
I use producer template quite a bit and it works well but it obviously is a bit more coupled to the Camel API than using the @Produce with an interface. The problem is I can't tell exactly when @Produce is going to work as I expect it to. Currently I have two routes, for example, one that makes a call to a direct route to do a look up and return a field during processing. It works fine. A second route that I have is similar but it sends a String fileName to a an error route to send and email via a velocity template. If I use the ProducerTemplate that works fine. If I use the @Produce what I end up with is the body rendered showing the BeanInvocation proxy itself with the actual body to be rendered contained with in it. I ran into this before in an different situation and ended up removing the @Produce although I was actually able to cause it to work correctly by an indirect bean call on it which seems to have cause the proxy to divulge its contents. In this particular case I'm invoking the interface which sends it to a second route that sets other information like to/from/subject and then uses a recipientList to invoke the velocity template I've specified for that particular error message. Brad
RE: HTTP POST with ProducerTemplate
Ok. I was able to figure this out. Changed my code to: Exchange response = template.send(endpoint, new HttpOutboundProcessor(exchange.getOut().getBody().toString())); Integer responseCode = (Integer)response.getOut().getHeader(Exchange.HTTP_RESPONSE_CODE); String responseBody = IOUtils.toString((InputStream)response.getOut().getBody()); And that seems to work. I created a new, local, HttpOutboundProcessor class: public class HttpOutboundProcessor implements Processor { private String exchangeBody; public HttpOutboundProcessor(String exchangeBody) { this.exchangeBody = exchangeBody; } @Override public void process(Exchange exchange) throws Exception { exchange.getIn().setHeader(Exchange.HTTP_METHOD, "POST"); exchange.getIn().setBody(exchangeBody); } } Thank you for the help. P.S. I tried replacing the whole exchange in the "process" method, but that caused issues. -- View this message in context: http://camel.465427.n5.nabble.com/HTTP-POST-with-ProducerTemplate-tp5785366p5785448.html Sent from the Camel - Users mailing list archive at Nabble.com.
RE: HTTP POST with ProducerTemplate
Ok...how or where would I set the body of the http post in that example? The new Processor could not have context to anything outside its constructor, right? -- View this message in context: http://camel.465427.n5.nabble.com/HTTP-POST-with-ProducerTemplate-tp5785366p5785430.html Sent from the Camel - Users mailing list archive at Nabble.com.
RE: HTTP POST with ProducerTemplate
Sorry I didn't read your question fully. We are defining it this way: Exchange exchange = template.send(URI, new Processor() { public void process(Exchange exchange) throws Exception { exchange.getIn().setHeader(Exchange.HTTP_METHOD, "POST"); } }); //Now you can get the out object and exchange.getOut().getHeader("CamelHttpResponseCode"); Hope this solves your problem. Regards, Arpit. -Original Message- From: Goyal, Arpit [mailto:arpit.go...@sap.com] Sent: Friday, July 22, 2016 11:16 AM To: users@camel.apache.org Subject: RE: HTTP POST with ProducerTemplate Hi Michael, I was going through our implementation and looks like in the response Exchange --> Out object --> there is Camel Header which has the status. Wasn't able to attach screenshot of my debug variables, but here it goes: DefaultExchange --> DefaultMessage (out object) --> CaseInsensitiveMap (headers object) --> CamelHttpResponseCode (property). Regards, Arpit. -Original Message- From: wheli [mailto:michael.wheli...@medfx.com] Sent: Friday, July 22, 2016 7:56 AM To: users@camel.apache.org Subject: HTTP POST with ProducerTemplate Hello, I am attempting to make an HTTP POST to an endpoint (using "https://httpbin.org/post; as a test), but am having trouble figuring out how to pull the HTTP response code (200, 404, etc...). I need to use a ProducerTemplate due to some other restrictions in my application. I looked the camel documentation and see some examples, but nothing that really matches what I am trying to do. My current code: public void sendExchangeToEndpoint(ProducerTemplate template, Exchange exchange, String endpoint) { String response = template.requestBody(endpoint, exchange.getOut().getBody(), String.class); . } This works and returns what I post (which is how httpbin works), but I am only getting the body back as a string. What would be the best way to get back a full exchange that would contain body, headers, etc... Any help would be greatly appreciated. Thanks! -- View this message in context: http://camel.465427.n5.nabble.com/HTTP-POST-with-ProducerTemplate-tp5785366.html Sent from the Camel - Users mailing list archive at Nabble.com.
RE: HTTP POST with ProducerTemplate
Hi Michael, I was going through our implementation and looks like in the response Exchange --> Out object --> there is Camel Header which has the status. Wasn't able to attach screenshot of my debug variables, but here it goes: DefaultExchange --> DefaultMessage (out object) --> CaseInsensitiveMap (headers object) --> CamelHttpResponseCode (property). Regards, Arpit. -Original Message- From: wheli [mailto:michael.wheli...@medfx.com] Sent: Friday, July 22, 2016 7:56 AM To: users@camel.apache.org Subject: HTTP POST with ProducerTemplate Hello, I am attempting to make an HTTP POST to an endpoint (using "https://httpbin.org/post; as a test), but am having trouble figuring out how to pull the HTTP response code (200, 404, etc...). I need to use a ProducerTemplate due to some other restrictions in my application. I looked the camel documentation and see some examples, but nothing that really matches what I am trying to do. My current code: public void sendExchangeToEndpoint(ProducerTemplate template, Exchange exchange, String endpoint) { String response = template.requestBody(endpoint, exchange.getOut().getBody(), String.class); . } This works and returns what I post (which is how httpbin works), but I am only getting the body back as a string. What would be the best way to get back a full exchange that would contain body, headers, etc... Any help would be greatly appreciated. Thanks! -- View this message in context: http://camel.465427.n5.nabble.com/HTTP-POST-with-ProducerTemplate-tp5785366.html Sent from the Camel - Users mailing list archive at Nabble.com.
HTTP POST with ProducerTemplate
Hello, I am attempting to make an HTTP POST to an endpoint (using "https://httpbin.org/post; as a test), but am having trouble figuring out how to pull the HTTP response code (200, 404, etc...). I need to use a ProducerTemplate due to some other restrictions in my application. I looked the camel documentation and see some examples, but nothing that really matches what I am trying to do. My current code: public void sendExchangeToEndpoint(ProducerTemplate template, Exchange exchange, String endpoint) { String response = template.requestBody(endpoint, exchange.getOut().getBody(), String.class); . } This works and returns what I post (which is how httpbin works), but I am only getting the body back as a string. What would be the best way to get back a full exchange that would contain body, headers, etc... Any help would be greatly appreciated. Thanks! -- View this message in context: http://camel.465427.n5.nabble.com/HTTP-POST-with-ProducerTemplate-tp5785366.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Camel Consumer not available within a Unit Test - ProducerTemplate
Problem resolved using context.stopRoute("direct-idempotent"); context.startRoute("direct-idempotent"); I suspect that how the thread is paused/resume when using startCamel() & stopCamelContext() is different from using stop/start route On Fri, May 27, 2016 at 12:25 PM, Charles Moulliard <ch0...@gmail.com> wrote: > Hi, > > I'm facing a strange issue that I don't understand. I can execute this > unit test case when I start the Test within IntelliJ but it will fail with > mvn clean test -Dtest= CamelIdempotentTest > > As you can see, I use the parent method stopCamelContext() and > startCamelContext() to stop and start the CamelContext. The test fails at > the end as the direct consumer is not available when called by the > producerTemplate > > Is there a workaround ? > > org.apache.camel.component.direct.DirectConsumerNotAvailableException: No > consumers available on endpoint: Endpoint[direct://data-insert]. > Exchange[Message: 333,18-05-2016,Claus,Ibsen,incident camel-333,this is a > report incident for camel-333,cib...@gmail.com,+111 10 20 300] > at > org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:47) > at > org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191) > at > org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109) > at > org.apache.camel.processor.UnitOfWorkProducer.process(UnitOfWorkProducer.java:68) > at > org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:375) > at > org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:343) > at org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:233) > at org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:343) > at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:201) > at > org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:128) > > Code > > public class CamelIdempotentTest extends CamelSpringTestSupport { > > @EndpointInject(uri="direct:data-insert") > ProducerTemplate template; > > @EndpointInject(uri="mock:result") > MockEndpoint mockResult; > > @Test > public void testStopStartCamelRoute() throws Exception { > mockResult.expectedMessageCount(1); > > template.requestBodyAndHeader("111,22-04-2016,Claus,Ibsen,incident > camel-111,this is a report incident for camel-111,cib...@gmail.com,+111 > 10 20 300","CamelRecord",1); > stopCamelContext(); > > Connection conn = null; > try { > Class.forName("org.h2.Driver"); > conn = > DriverManager.getConnection("jdbc:h2:mem:idempotentReport"); > Statement stmt = conn.createStatement(); > ResultSet rs = stmt.executeQuery("select * from > CAMEL_MESSAGEPROCESSED"); > while (rs.next()) { > Assert.assertEquals("1",rs.getString("messageId")); > > Assert.assertEquals("DirectConsumer",rs.getString("processorName")); > } > } catch(Exception e) { > System.out.print("Something happened"); > } finally { > conn.close(); > } > > try { > template.start(); > > template.requestBodyAndHeader("111,22-04-2016,Claus,Ibsen,incident > camel-111,this is a report incident for camel-111,cib...@gmail.com,+111 > 10 20 300","CamelRecord",1); > > } catch(CamelExecutionException e) { > System.out.println("&&&&& The consumer endpoint is not started > so we can't use it"); > } > > startCamelContext(); > context().getRoute("direct-idempotent").getConsumer().start(); > template.requestBodyAndHeader("333,18-05-2016,Claus,Ibsen,incident > camel-333,this is a report incident for camel-333,cib...@gmail.com,+111 > 10 20 300","CamelRecord",1); > > mockResult.assertIsSatisfied(); > } > > Regards, > > -- > Charles Moulliard > Apache Committer & PMC / Architect @RedHat > Twitter : @cmoulliard | Blog : http://cmoulliard.github.io > > -- Charles Moulliard Apache Committer & PMC / Architect @RedHat Twitter : @cmoulliard | Blog : http://cmoulliard.github.io
Camel Consumer not available within a Unit Test - ProducerTemplate
Hi, I'm facing a strange issue that I don't understand. I can execute this unit test case when I start the Test within IntelliJ but it will fail with mvn clean test -Dtest= CamelIdempotentTest As you can see, I use the parent method stopCamelContext() and startCamelContext() to stop and start the CamelContext. The test fails at the end as the direct consumer is not available when called by the producerTemplate Is there a workaround ? org.apache.camel.component.direct.DirectConsumerNotAvailableException: No consumers available on endpoint: Endpoint[direct://data-insert]. Exchange[Message: 333,18-05-2016,Claus,Ibsen,incident camel-333,this is a report incident for camel-333,cib...@gmail.com,+111 10 20 300] at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:47) at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191) at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109) at org.apache.camel.processor.UnitOfWorkProducer.process(UnitOfWorkProducer.java:68) at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:375) at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:343) at org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:233) at org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:343) at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:201) at org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:128) Code public class CamelIdempotentTest extends CamelSpringTestSupport { @EndpointInject(uri="direct:data-insert") ProducerTemplate template; @EndpointInject(uri="mock:result") MockEndpoint mockResult; @Test public void testStopStartCamelRoute() throws Exception { mockResult.expectedMessageCount(1); template.requestBodyAndHeader("111,22-04-2016,Claus,Ibsen,incident camel-111,this is a report incident for camel-111,cib...@gmail.com,+111 10 20 300","CamelRecord",1); stopCamelContext(); Connection conn = null; try { Class.forName("org.h2.Driver"); conn = DriverManager.getConnection("jdbc:h2:mem:idempotentReport"); Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery("select * from CAMEL_MESSAGEPROCESSED"); while (rs.next()) { Assert.assertEquals("1",rs.getString("messageId")); Assert.assertEquals("DirectConsumer",rs.getString("processorName")); } } catch(Exception e) { System.out.print("Something happened"); } finally { conn.close(); } try { template.start(); template.requestBodyAndHeader("111,22-04-2016,Claus,Ibsen,incident camel-111,this is a report incident for camel-111,cib...@gmail.com,+111 10 20 300","CamelRecord",1); } catch(CamelExecutionException e) { System.out.println("&&&&& The consumer endpoint is not started so we can't use it"); } startCamelContext(); context().getRoute("direct-idempotent").getConsumer().start(); template.requestBodyAndHeader("333,18-05-2016,Claus,Ibsen,incident camel-333,this is a report incident for camel-333,cib...@gmail.com,+111 10 20 300","CamelRecord",1); mockResult.assertIsSatisfied(); } Regards, -- Charles Moulliard Apache Committer & PMC / Architect @RedHat Twitter : @cmoulliard | Blog : http://cmoulliard.github.io
Re: ProducerTemplate not able to unmarshal response to Java object.
Do you actually get a response here? Contact contact = producerTemplate.requestBodyAndHeaders( "http://localhost:8080/api/contact/2345;, null, headers, Contact.class); Check if contact is not null before you try to unmarshal. On Tue, May 24, 2016 at 11:17 AM, ndsurendra [via Camel] < ml-node+s465427n578301...@n5.nabble.com> wrote: > I used the ProducerTemplate to send a http request and get the response > like this. > > Contact contact = producerTemplate.requestBodyAndHeaders( > "http://localhost:8080/api/contact/2345;, > null, headers, Contact.class); > > logger.info("Contact is: " + new > ObjectMapper().writeValueAsString(contact)); > > I get the contact as null. > > > When I try to get it as Object like this: > > Object contact = producerTemplate.requestBodyAndHeaders( > "http://localhost:8080/api/contact/2345;, > null, headers); > > > logger.info("Contact is: " + new > ObjectMapper().writeValueAsString(contact)); > > com.fasterxml.jackson.databind.JsonMappingException: No serializer found > for class > org.apache.camel.converter.stream.CachedOutputStream$WrappedInputStream and > no properties discovered to create BeanSerializer (to avoid exception, > disable SerializationFeature.FAIL_ON_EMPTY_BEANS) ) > > > Why is ProducerTemplate not able to unmarshall the response to the > specified object? > How can this be achieved? > > Thanks, > Surendra. > > -- > If you reply to this email, your message will be added to the discussion > below: > > http://camel.465427.n5.nabble.com/ProducerTemplate-not-able-to-unmarshal-response-to-Java-object-tp5783011.html > To start a new topic under Camel - Users, email > ml-node+s465427n465428...@n5.nabble.com > To unsubscribe from Camel - Users, click here > <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code=465428=c291Y2lhbmNlLmVxZGFtLnJhc2h0aUBnbWFpbC5jb218NDY1NDI4fDE1MzI5MTE2NTY=> > . > NAML > <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer=instant_html%21nabble%3Aemail.naml=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml> > -- View this message in context: http://camel.465427.n5.nabble.com/ProducerTemplate-not-able-to-unmarshal-response-to-Java-object-tp5783011p5783026.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: ProducerTemplate not able to unmarshal response to Java object.
Hi Sashika, I am producing the request to an existing rest service (Contact service in this case) and the service is returning the response as well. The only problem is, I am not able to unmarshal/deserialize the response into a Java object. The response is of type org.apache.camel.converter.stream.CachedOutputStream$WrappedInputStream I was wondering if there is anyway the ProducerTemplate handles this data format conversions automatically. Thanks! -- View this message in context: http://camel.465427.n5.nabble.com/ProducerTemplate-not-able-to-unmarshal-response-to-Java-object-tp5783011p5783025.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: ProducerTemplate not able to unmarshal response to Java object.
Producer template can produce to camel end points. Setup a camel route with http component and configure the given url in it. Now produce to that endpoint and convert the response to the required object type. Hope this helps On Tue, May 24, 2016 2:47 PM, ndsurendra ndsuren...@gmail.com wrote: I used the ProducerTemplate to send a http request and get the response like this. Contact contact = producerTemplate.requestBodyAndHeaders( "http://localhost:8080/api/contact/2345;, null, headers, Contact.class); logger.info("Contact is: " + new ObjectMapper().writeValueAsString(contact)); I get the contact as null. When I try to get it as Object like this: Object contact = producerTemplate.requestBodyAndHeaders( "http://localhost:8080/api/contact/2345;, null, headers); logger.info("Contact is: " + new ObjectMapper().writeValueAsString(contact)); com.fasterxml.jackson.databind.JsonMappingException: No serializer found for class org.apache.camel.converter.stream.CachedOutputStream$WrappedInputStream and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) ) Why is ProducerTemplate not able to unmarshall the response to the specified object? How can this be achieved? Thanks, Surendra. -- View this message in context: http://camel.465427.n5.nabble.com/ProducerTemplate-not-able-to-unmarshal-response-to-Java-object-tp5783011.html Sent from the Camel - Users mailing list archive at Nabble.com.
ProducerTemplate not able to unmarshal response to Java object.
I used the ProducerTemplate to send a http request and get the response like this. Contact contact = producerTemplate.requestBodyAndHeaders( "http://localhost:8080/api/contact/2345;, null, headers, Contact.class); logger.info("Contact is: " + new ObjectMapper().writeValueAsString(contact)); I get the contact as null. When I try to get it as Object like this: Object contact = producerTemplate.requestBodyAndHeaders( "http://localhost:8080/api/contact/2345;, null, headers); logger.info("Contact is: " + new ObjectMapper().writeValueAsString(contact)); com.fasterxml.jackson.databind.JsonMappingException: No serializer found for class org.apache.camel.converter.stream.CachedOutputStream$WrappedInputStream and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) ) Why is ProducerTemplate not able to unmarshall the response to the specified object? How can this be achieved? Thanks, Surendra. -- View this message in context: http://camel.465427.n5.nabble.com/ProducerTemplate-not-able-to-unmarshal-response-to-Java-object-tp5783011.html Sent from the Camel - Users mailing list archive at Nabble.com.
Issue with ProducerTemplate send. Null value going as String.
Hi All, I calling send method of ProducerTemplate with my endpoint as follows producerTemplate.send("abcd:addAttribute?operationName=execute@"+index+"=ERROR_CODE=${property.errorCode}", exchange); Later I decided to construct the endpoint uri separately as string as this template was getting used many times producerTemplate.send(constructEndpoint(),exchange); constructEndpoint(Strign index, String value) { return "abcd:addAttribute?operationName=execute@"+index+"=ERROR_CODE=" + value; Things starts breaking when property.errorCode is null. Method constructEndpoint returns endpoint string with attributeValu as null which gets evaluated by producerTemplate as String null i.e. "null" Any idea how to overcome this situation ? -- View this message in context: http://camel.465427.n5.nabble.com/Issue-with-ProducerTemplate-send-Null-value-going-as-String-tp5775031.html Sent from the Camel - Users mailing list archive at Nabble.com.
How do you define the camel ProducerTemplate?
Hi, I have been going through the redhat documentation for camel and see that the definiton of a ProducerTemplate is described as "The producer template supports a variety of different approaches to invoking producer endpoints. There are methods that support different formats for the request message " Isn't a producer template is used to produce messages into a route? i.e., to a consumer endpoint. How can a producer template be used / defined as an entity to produce messages to a producer endpoint itself? Can someone please elaborate? Link: https://access.redhat.com/documentation/en-US/Red_Hat_JBoss_Fuse/6.2/html/Apache_Camel_Development_Guide/Templates.html#Templates-Producer Note - I am not sure if this is the right forum to raise this question as the content i am referring to is related to redhat documentation for fuse product. Thanks, Kalyan -- View this message in context: http://camel.465427.n5.nabble.com/How-do-you-define-the-camel-ProducerTemplate-tp5774460.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: How do you define the camel ProducerTemplate?
On Fri, Nov 27, 2015 at 7:53 AM, calyan.bandi <calyan.ba...@gmail.com> wrote: > Hi, > > I have been going through the redhat documentation for camel and see that > the definiton of a ProducerTemplate is described as > > "The producer template supports a variety of different approaches to > invoking producer endpoints. There are methods that support different > formats for the request message " > Yeah the sentence could be better. It is used to produce (= send) a message, which is the producer of the endpoint that is used (invoked) to do the actual sending. For example you can send a message to a remote message broker. > Isn't a producer template is used to produce messages into a route? i.e., to > a consumer endpoint. How can a producer template be used / defined as an > entity to produce messages to a producer endpoint itself? Can someone please > elaborate? > No the receive of the message may not be Camel, it could be some other system. However if its Camel then the receive is called (consumer) and it consume the message. The term consumer and producer comes from the EIP book. > > Link: > https://access.redhat.com/documentation/en-US/Red_Hat_JBoss_Fuse/6.2/html/Apache_Camel_Development_Guide/Templates.html#Templates-Producer > > Note - I am not sure if this is the right forum to raise this question as > the content i am referring to is related to redhat documentation for fuse > product. > > Thanks, > Kalyan > > > > -- > View this message in context: > http://camel.465427.n5.nabble.com/How-do-you-define-the-camel-ProducerTemplate-tp5774460.html > Sent from the Camel - Users mailing list archive at Nabble.com. -- Claus Ibsen - http://davsclaus.com @davsclaus Camel in Action 2: https://www.manning.com/ibsen2
Re: Spring-Boot + Camel + producerTemplate ssh spawning thousands of threads
This bit is definitely a bug. Whether it's something in the component, or the SshClient library needs to be investigated. You should log this one in a Jira. On 12/11/15 16:42, codan84 wrote: Indeed the ClientSession of SshClient is being started, but never finished. Here are logs: 2015-11-12 16:39:08 [sshd-SshClient[68c05218]-nio2-thread-1] INFO o.a.s.c.session.ClientSessionImpl - Client session created 2015-11-12 16:39:08 [sshd-SshClient[68c05218]-nio2-thread-2] INFO o.a.s.c.session.ClientSessionImpl - Server version string: SSH-1.99-OpenSSH_3.9p1 2015-11-12 16:39:08 [sshd-SshClient[68c05218]-nio2-thread-3] INFO o.a.s.c.session.ClientSessionImpl - Kex: server->client aes128-ctr hmac-sha1 none 2015-11-12 16:39:08 [sshd-SshClient[68c05218]-nio2-thread-3] INFO o.a.s.c.session.ClientSessionImpl - Kex: client->server aes128-ctr hmac-sha1 none 2015-11-12 16:39:09 [sshd-SshClient[68c05218]-nio2-thread-5] WARN o.a.s.c.k.AcceptAllServerKeyVerifier - Server at *** presented unverified DSA key: *** Script output :) This just repeats for every call. -- View this message in context: http://camel.465427.n5.nabble.com/Spring-Boot-Camel-producerTemplate-ssh-spawning-thousands-of-threads-tp5773741p5773762.html Sent from the Camel - Users mailing list archive at Nabble.com.
Spring-Boot + Camel + producerTemplate ssh spawning thousands of threads
I did write a simple app using Spring Boot (1.2.7.RELEASE) and Apache Camel (2.15.0). The app is simple and has only 1 route: a timer will invoke a method on a bean every 1s. The method invoked will use ProducerTemplate to ssh into a remote machine, execute a small script, and print out the output to the console. Simple, right? However, when profiling this, I can see the number of threads! It seems like any threads created for the ssh are never killed, but parked instead. Because of that I run OOM pretty quickly with an error: Exception in thread "Thread-341" java.lang.OutOfMemoryError: unable to create new native thread More description and profiler results can be found on stackoverflow: http://stackoverflow.com/questions/33671567/spring-boot-camel-producertemplate-memory-leak I think this is a bug, as from the documentation I can't see that I am using the ProducerTemplate wrongly. Or am I? If so, please tell me. If I am doing things right and it seems like a bug, I will submit it... -- View this message in context: http://camel.465427.n5.nabble.com/Spring-Boot-Camel-producerTemplate-ssh-spawning-thousands-of-threads-tp5773741.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Spring-Boot + Camel + producerTemplate ssh spawning thousands of threads
To work out if it's your use of the ProducerTemplate, try the following route instead and see whether the leak persists: from("timer://foo?period=1000") .transform().constant("/home/_username_/some_temp_script.sh") .to("ssh://_remote.machine.url.here_?username=_username_=#keyPairProvider") .log("Received: ${body}"); On 12/11/15 14:35, codan84 wrote: I did write a simple app using Spring Boot (1.2.7.RELEASE) and Apache Camel (2.15.0). The app is simple and has only 1 route: a timer will invoke a method on a bean every 1s. The method invoked will use ProducerTemplate to ssh into a remote machine, execute a small script, and print out the output to the console. Simple, right? However, when profiling this, I can see the number of threads! It seems like any threads created for the ssh are never killed, but parked instead. Because of that I run OOM pretty quickly with an error: Exception in thread "Thread-341" java.lang.OutOfMemoryError: unable to create new native thread More description and profiler results can be found on stackoverflow: http://stackoverflow.com/questions/33671567/spring-boot-camel-producertemplate-memory-leak I think this is a bug, as from the documentation I can't see that I am using the ProducerTemplate wrongly. Or am I? If so, please tell me. If I am doing things right and it seems like a bug, I will submit it... -- View this message in context: http://camel.465427.n5.nabble.com/Spring-Boot-Camel-producerTemplate-ssh-spawning-thousands-of-threads-tp5773741.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Spring-Boot + Camel + producerTemplate ssh spawning thousands of threads
Maybe your bean with the producer template is not singleton scoped, so spring creates a new instance per message. On Thu, Nov 12, 2015 at 4:10 PM, codan84 <daniel.gruszc...@live.com> wrote: > Hmm Interesting, this indeed fixes the problem. I am forced to use a > producerTemplate tho... Any ideas what am I doing wrong? > > > > -- > View this message in context: > http://camel.465427.n5.nabble.com/Spring-Boot-Camel-producerTemplate-ssh-spawning-thousands-of-threads-tp5773741p5773747.html > Sent from the Camel - Users mailing list archive at Nabble.com. -- Claus Ibsen - http://davsclaus.com @davsclaus Camel in Action 2: https://www.manning.com/ibsen2
Re: Spring-Boot + Camel + producerTemplate ssh spawning thousands of threads
Hmm Interesting, this indeed fixes the problem. I am forced to use a producerTemplate tho... Any ideas what am I doing wrong? -- View this message in context: http://camel.465427.n5.nabble.com/Spring-Boot-Camel-producerTemplate-ssh-spawning-thousands-of-threads-tp5773741p5773747.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Spring-Boot + Camel + producerTemplate ssh spawning thousands of threads
I have tried similar thing, but with sftp rather than ssh. Everything else is exactly the same: producerTemplate.sendBodyAndHeader( "sftp://_target_machine_url_?username=_username_; + "=" + sshKeyPath + "=" + knownHosts + "=publickey", new ByteArrayInputStream(new String("Random junk").getBytes()), "CamelFileName", "/home/_username_/test_file.txt" ); And this works fine. So it is not the way I am using ProducerTemplate. It is a bug with ssh when using producer template, or "requestBody" method... -- View this message in context: http://camel.465427.n5.nabble.com/Spring-Boot-Camel-producerTemplate-ssh-spawning-thousands-of-threads-tp5773741p5773751.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Spring-Boot + Camel + producerTemplate ssh spawning thousands of threads
In that case starting/stopping it should in theory release threads, right? I tried start->requestBody->stop, without effect, still all threads keep running. I also tried to instantiate new template for each call, start it and stop at the end, still the same. -- View this message in context: http://camel.465427.n5.nabble.com/Spring-Boot-Camel-producerTemplate-ssh-spawning-thousands-of-threads-tp5773741p5773750.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Spring-Boot + Camel + producerTemplate ssh spawning thousands of threads
I tried your suggestion: ProducerTemplate producerTemplate = camelContext.createProducerTemplate(); producerTemplate.start(); String response = producerTemplate.requestBody("ssh://", String.class); producerTemplate.stop(); There is no difference. Still the number of threads grows. I would disagree that this is not a bug. Especially with a Spring-Boot application, where the app will usually run on a server forever, this is an issue. It is unfortunate how Camel handles non-singleton endpoints, but it should either be very well documented (bold, red etc), or a different approach to non-singleton endpoints worked out. -- View this message in context: http://camel.465427.n5.nabble.com/Spring-Boot-Camel-producerTemplate-ssh-spawning-thousands-of-threads-tp5773741p5773755.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Spring-Boot + Camel + producerTemplate ssh spawning thousands of threads
Indeed the ClientSession of SshClient is being started, but never finished. Here are logs: 2015-11-12 16:39:08 [sshd-SshClient[68c05218]-nio2-thread-1] INFO o.a.s.c.session.ClientSessionImpl - Client session created 2015-11-12 16:39:08 [sshd-SshClient[68c05218]-nio2-thread-2] INFO o.a.s.c.session.ClientSessionImpl - Server version string: SSH-1.99-OpenSSH_3.9p1 2015-11-12 16:39:08 [sshd-SshClient[68c05218]-nio2-thread-3] INFO o.a.s.c.session.ClientSessionImpl - Kex: server->client aes128-ctr hmac-sha1 none 2015-11-12 16:39:08 [sshd-SshClient[68c05218]-nio2-thread-3] INFO o.a.s.c.session.ClientSessionImpl - Kex: client->server aes128-ctr hmac-sha1 none 2015-11-12 16:39:09 [sshd-SshClient[68c05218]-nio2-thread-5] WARN o.a.s.c.k.AcceptAllServerKeyVerifier - Server at *** presented unverified DSA key: *** Script output :) This just repeats for every call. -- View this message in context: http://camel.465427.n5.nabble.com/Spring-Boot-Camel-producerTemplate-ssh-spawning-thousands-of-threads-tp5773741p5773762.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Spring-Boot + Camel + producerTemplate ssh spawning thousands of threads
When you use the SSH producer endpoint in a to(..) statement, one instance of the endpoint is created within the route, its lifecycle is tied to the CamelContext and any resources used by it will be cleaned up at shutdown. The endpoint creates an instance of an SshClient (underlying library), and closes it when the context shuts down. When you use it through a ProducerTemplate, each time you access the send() method it creates a new instance of the SshEndpoint, allocating memory on the way by creating a new underlying SshClient instance. This behaviour is dictated by SshEndpoint. isSingleton(), which returns false as the underlying client library is not thread-safe. You need to close the ProducerTemplate in order to close the SshClient instance (note, nothing to do with the SSH connection itself). As a workaround, you might consider having the CamelContext injected into your bean, and for each request do: ProducerTemplate template = context.createProducerTemplate(); template.sendBody(...); template.close(); It's expensive, but it will do the job. I don't think this is a bug, if seems to be a side-effect of how a ProducerTemplate works with non-singleton endpoints. If there were multiple threads, then the ProducerTemplate would have to create multiple endpoints for the underlying library to work correctly, and for the threads to not trip over each other. In your case, only one thread will ever be using that one ProducerTemplate, so it doesn't make sense. The ProducerTemplate can't know in advance how many threads will be accessing it. On 12/11/15 15:10, codan84 wrote: Hmm Interesting, this indeed fixes the problem. I am forced to use a producerTemplate tho... Any ideas what am I doing wrong? -- View this message in context: http://camel.465427.n5.nabble.com/Spring-Boot-Camel-producerTemplate-ssh-spawning-thousands-of-threads-tp5773741p5773747.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: ProducerTemplate creates too much threads
You can use the addService api on CamelContext - see its javadoc On Tue, Oct 20, 2015 at 1:55 PM, Shylendran C <shylendra...@gmail.com> wrote: > Thanks for your reply. > So, just want to confirm - no need to put the start() and stop() for each > thread, is that correct? > And, our application will be running for ever (untill we manually kill the > process), so I am not sure where to put the stop() method. Any suggestions? > > Thanks again, > Shylendran.C > > On Tue, Oct 20, 2015 at 1:06 AM, Claus Ibsen <claus.ib...@gmail.com> wrote: > >> Dont start / stop it all the time, create it once and reuse it, and >> stop it when you stop your app. >> >> On Tue, Oct 20, 2015 at 6:17 AM, shylendran.c <shylendra...@gmail.com> >> wrote: >> > Hi, >> > I am using camel-code-2.15.2.jar. I have a multi-threaded application >> where >> > I have to send message continuously and I am using >> > org.apache.camel.ProducerTemplate. But since it is a multi-threaded, it >> is >> > breaking and getting the below exceptions. So, I've tried with 'static >> > synchronized' where everything is working, but we can't go with 'static >> > synchronized'. So looking for a solution. >> > It is clear that the exception is happening when we have >> > ProducerTemplate.start() and stop() when multi-threads are invoking >> this. We >> > have created only one instance of ProducerTemplate. >> > >> > Is there a way which I can check whether the producer template is already >> > 'open' or 'stop'. I see few protected variables, and while debugging I >> see >> > exactly what I am looking. >> > Please let me know your opinion on this. >> > >> > class RMThread implements Runnable { >> > >> > ... >> > . >> > public void run() { >> > if (producerTemp != null) { >> > >> > producerTemp.start(); >> > producerTemp.sendBodyAndHeaders("", "", map); >> > producerTemp.stop(); >> > . >> > .. >> > } >> > } >> > >> > public class MainClass { >> > >> > ProducerTemplate producerTemplate = null; >> > producerTemplate = configureRoutes.getContext().createProducerTemplate(); >> > >> > ServerSocket ss = new ServerSocket(111 >> > while (true) { >> > new Thread(new RMThread(ss.accept(), log, producerTemplate, >> > producerTemplate_sendTransferMetrics)).start(); >> > >> > } >> > >> > >> > Exceptions:: >> > org.apache.camel.CamelExecutionException: Exception occurred during >> > execution on the exchange: Exchange[Message: ] >> > at >> > >> org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1635) >> > >> > Caused by: java.lang.IllegalStateException: Pool not open >> > at >> > >> org.apache.commons.pool.BaseObjectPool.assertOpen(BaseObjectPool.java:140) >> > ... >> > >> > >> > Thanks, >> > Shylendran.C >> > >> > >> > >> > >> > -- >> > View this message in context: >> http://camel.465427.n5.nabble.com/ProducerTemplate-creates-too-much-threads-tp5751299p5772885.html >> > Sent from the Camel - Users mailing list archive at Nabble.com. >> >> >> >> -- >> Claus Ibsen >> - >> http://davsclaus.com @davsclaus >> Camel in Action 2nd edition: >> https://www.manning.com/books/camel-in-action-second-edition >> -- Claus Ibsen - http://davsclaus.com @davsclaus Camel in Action 2nd edition: https://www.manning.com/books/camel-in-action-second-edition
Re: ProducerTemplate creates too much threads
Thanks for your reply. So, just want to confirm - no need to put the start() and stop() for each thread, is that correct? And, our application will be running for ever (untill we manually kill the process), so I am not sure where to put the stop() method. Any suggestions? Thanks again, Shylendran.C On Tue, Oct 20, 2015 at 1:06 AM, Claus Ibsen <claus.ib...@gmail.com> wrote: > Dont start / stop it all the time, create it once and reuse it, and > stop it when you stop your app. > > On Tue, Oct 20, 2015 at 6:17 AM, shylendran.c <shylendra...@gmail.com> > wrote: > > Hi, > > I am using camel-code-2.15.2.jar. I have a multi-threaded application > where > > I have to send message continuously and I am using > > org.apache.camel.ProducerTemplate. But since it is a multi-threaded, it > is > > breaking and getting the below exceptions. So, I've tried with 'static > > synchronized' where everything is working, but we can't go with 'static > > synchronized'. So looking for a solution. > > It is clear that the exception is happening when we have > > ProducerTemplate.start() and stop() when multi-threads are invoking > this. We > > have created only one instance of ProducerTemplate. > > > > Is there a way which I can check whether the producer template is already > > 'open' or 'stop'. I see few protected variables, and while debugging I > see > > exactly what I am looking. > > Please let me know your opinion on this. > > > > class RMThread implements Runnable { > > > > ... > > . > > public void run() { > > if (producerTemp != null) { > > > > producerTemp.start(); > > producerTemp.sendBodyAndHeaders("", "", map); > > producerTemp.stop(); > > . > > .. > > } > > } > > > > public class MainClass { > > > > ProducerTemplate producerTemplate = null; > > producerTemplate = configureRoutes.getContext().createProducerTemplate(); > > > > ServerSocket ss = new ServerSocket(111 > > while (true) { > > new Thread(new RMThread(ss.accept(), log, producerTemplate, > > producerTemplate_sendTransferMetrics)).start(); > > > > } > > > > > > Exceptions:: > > org.apache.camel.CamelExecutionException: Exception occurred during > > execution on the exchange: Exchange[Message: ] > > at > > > org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1635) > > > > Caused by: java.lang.IllegalStateException: Pool not open > > at > > > org.apache.commons.pool.BaseObjectPool.assertOpen(BaseObjectPool.java:140) > > ... > > > > > > Thanks, > > Shylendran.C > > > > > > > > > > -- > > View this message in context: > http://camel.465427.n5.nabble.com/ProducerTemplate-creates-too-much-threads-tp5751299p5772885.html > > Sent from the Camel - Users mailing list archive at Nabble.com. > > > > -- > Claus Ibsen > - > http://davsclaus.com @davsclaus > Camel in Action 2nd edition: > https://www.manning.com/books/camel-in-action-second-edition >
Re: ProducerTemplate creates too much threads
Dont start / stop it all the time, create it once and reuse it, and stop it when you stop your app. On Tue, Oct 20, 2015 at 6:17 AM, shylendran.c <shylendra...@gmail.com> wrote: > Hi, > I am using camel-code-2.15.2.jar. I have a multi-threaded application where > I have to send message continuously and I am using > org.apache.camel.ProducerTemplate. But since it is a multi-threaded, it is > breaking and getting the below exceptions. So, I've tried with 'static > synchronized' where everything is working, but we can't go with 'static > synchronized'. So looking for a solution. > It is clear that the exception is happening when we have > ProducerTemplate.start() and stop() when multi-threads are invoking this. We > have created only one instance of ProducerTemplate. > > Is there a way which I can check whether the producer template is already > 'open' or 'stop'. I see few protected variables, and while debugging I see > exactly what I am looking. > Please let me know your opinion on this. > > class RMThread implements Runnable { > > ... > . > public void run() { > if (producerTemp != null) { > > producerTemp.start(); > producerTemp.sendBodyAndHeaders("", "", map); > producerTemp.stop(); > . > ...... > } > } > > public class MainClass { > > ProducerTemplate producerTemplate = null; > producerTemplate = configureRoutes.getContext().createProducerTemplate(); > > ServerSocket ss = new ServerSocket(111 > while (true) { > new Thread(new RMThread(ss.accept(), log, producerTemplate, > producerTemplate_sendTransferMetrics)).start(); > > } > > > Exceptions:: > org.apache.camel.CamelExecutionException: Exception occurred during > execution on the exchange: Exchange[Message: ] > at > org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1635) > > Caused by: java.lang.IllegalStateException: Pool not open > at > org.apache.commons.pool.BaseObjectPool.assertOpen(BaseObjectPool.java:140) > ... > > > Thanks, > Shylendran.C > > > > > -- > View this message in context: > http://camel.465427.n5.nabble.com/ProducerTemplate-creates-too-much-threads-tp5751299p5772885.html > Sent from the Camel - Users mailing list archive at Nabble.com. -- Claus Ibsen - http://davsclaus.com @davsclaus Camel in Action 2nd edition: https://www.manning.com/books/camel-in-action-second-edition
Re: ProducerTemplate creates too much threads
Hi, I am using camel-code-2.15.2.jar. I have a multi-threaded application where I have to send message continuously and I am using org.apache.camel.ProducerTemplate. But since it is a multi-threaded, it is breaking and getting the below exceptions. So, I've tried with 'static synchronized' where everything is working, but we can't go with 'static synchronized'. So looking for a solution. It is clear that the exception is happening when we have ProducerTemplate.start() and stop() when multi-threads are invoking this. We have created only one instance of ProducerTemplate. Is there a way which I can check whether the producer template is already 'open' or 'stop'. I see few protected variables, and while debugging I see exactly what I am looking. Please let me know your opinion on this. class RMThread implements Runnable { ... . public void run() { if (producerTemp != null) { producerTemp.start(); producerTemp.sendBodyAndHeaders("", "", map); producerTemp.stop(); . .. } } public class MainClass { .... ProducerTemplate producerTemplate = null; producerTemplate = configureRoutes.getContext().createProducerTemplate(); ServerSocket ss = new ServerSocket(111 while (true) { new Thread(new RMThread(ss.accept(), log, producerTemplate, producerTemplate_sendTransferMetrics)).start(); } Exceptions:: org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[Message: ] at org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1635) Caused by: java.lang.IllegalStateException: Pool not open at org.apache.commons.pool.BaseObjectPool.assertOpen(BaseObjectPool.java:140) ... Thanks, Shylendran.C -- View this message in context: http://camel.465427.n5.nabble.com/ProducerTemplate-creates-too-much-threads-tp5751299p5772885.html Sent from the Camel - Users mailing list archive at Nabble.com.
Camel 2.16.0: ProducerTemplate has not been started
Hi, I upgraded my project to the last 2.16.0 camel release and I get this exception in karaf 4.0.2 while it's working in my unit test. So basically, I've a bean with a private field declared as : @Produce private ProducerTemplate template; When I try to request and endpoint with my ProducerTemplate, I get the following exception : java.lang.IllegalStateException: ProducerTemplate has not been started at org.apache.camel.impl.DefaultProducerTemplate.getProducerCache(DefaultProducerTemplate.java:704) at org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:128) at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:132) at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:149) at org.apache.camel.impl.DefaultProducerTemplate.requestBody(DefaultProducerTemplate.java:301) at org.apache.camel.impl.DefaultProducerTemplate.requestBody(DefaultProducerTemplate.java:331) at be.lampiris.api.customer.impl.CustomerQueryServiceImpl.query(CustomerQueryServiceImpl.java:65) at Proxy35383b7f_3e97_49a0_89d0_cfa78fdbbae9.query(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.8.0_45] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)[:1.8.0_45] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.8.0_45] at java.lang.reflect.Method.invoke(Method.java:497)[:1.8.0_45] at org.apache.camel.component.bean.MethodInfo.invoke(MethodInfo.java:408)[96:org.apache.camel.camel-core:2.16.0] at org.apache.camel.component.bean.MethodInfo$1.doProceed(MethodInfo.java:279)[96:org.apache.camel.camel-core:2.16.0] at org.apache.camel.component.bean.MethodInfo$1.proceed(MethodInfo.java:252)[96:org.apache.camel.camel-core:2.16.0] at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:177)[96:org.apache.camel.camel-core:2.16.0] at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109)[96:org.apache.camel.camel-core:2.16.0] at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:68)[96:org.apache.camel.camel-core:2.16.0] at org.apache.camel.component.bean.BeanProducer.process(BeanProducer.java:38)[96:org.apache.camel.camel-core:2.16.0] at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:141)[96:org.apache.camel.camel-core:2.16.0] at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)[96:org.apache.camel.camel-core:2.16.0] at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:460)[96:org.apache.camel.camel-core:2.16.0] at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:190)[96:org.apache.camel.camel-core:2.16.0] at org.apache.camel.processor.Pipeline.process(Pipeline.java:121)[96:org.apache.camel.camel-core:2.16.0] at org.apache.camel.processor.Pipeline.process(Pipeline.java:83)[96:org.apache.camel.camel-core:2.16.0] at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:190)[96:org.apache.camel.camel-core:2.16.0] at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:62)[96:org.apache.camel.camel-core:2.16.0] at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:141)[96:org.apache.camel.camel-core:2.16.0] at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)[96:org.apache.camel.camel-core:2.16.0] at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:460)[96:org.apache.camel.camel-core:2.16.0] at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:190)[96:org.apache.camel.camel-core:2.16.0] at org.apache.camel.processor.Pipeline.process(Pipeline.java:121)[96:org.apache.camel.camel-core:2.16.0] at org.apache.camel.processor.Pipeline.process(Pipeline.java:83)[96:org.apache.camel.camel-core:2.16.0] at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:190)[96:org.apache.camel.camel-core:2.16.0] at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109)[96:org.apache.camel.camel-core:2.16.0] at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:87)[96:org.apache.camel.camel-core:2.16.0] at org.apache.camel.http.common.CamelServlet.service(CamelServlet.java:143)[99:org.apache.camel.camel-http-common:2.16.0] at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)[81:javax.servlet-api:3.1.0] at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:808)[215:org.eclipse.jetty.servlet:9.2.10.v20150310] at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:587)[215:org.eclipse.jetty.servlet:9.2.10.v20150310] at org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:70)[245:org.ops4j.pax.web.pax-web
Re: Camel 2.16.0: ProducerTemplate has not been started
The bug seems to be related with karaf and not with camel as it works in karaf 2.4.3 and karaf 3.0.5. On Tue, Oct 13, 2015 at 1:59 PM Arnaud Deprez <arnaudep...@gmail.com> wrote: > Hi, > > I upgraded my project to the last 2.16.0 camel release and I get this > exception in karaf 4.0.2 while it's working in my unit test. > > So basically, I've a bean with a private field declared as : > @Produce > private ProducerTemplate template; > > When I try to request and endpoint with my ProducerTemplate, I get the > following exception : > > java.lang.IllegalStateException: ProducerTemplate has not been started > at > org.apache.camel.impl.DefaultProducerTemplate.getProducerCache(DefaultProducerTemplate.java:704) > at > org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:128) > at > org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:132) > at > org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:149) > at > org.apache.camel.impl.DefaultProducerTemplate.requestBody(DefaultProducerTemplate.java:301) > at > org.apache.camel.impl.DefaultProducerTemplate.requestBody(DefaultProducerTemplate.java:331) > at > be.lampiris.api.customer.impl.CustomerQueryServiceImpl.query(CustomerQueryServiceImpl.java:65) > at Proxy35383b7f_3e97_49a0_89d0_cfa78fdbbae9.query(Unknown Source) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.8.0_45] > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)[:1.8.0_45] > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.8.0_45] > at java.lang.reflect.Method.invoke(Method.java:497)[:1.8.0_45] > at > org.apache.camel.component.bean.MethodInfo.invoke(MethodInfo.java:408)[96:org.apache.camel.camel-core:2.16.0] > at > org.apache.camel.component.bean.MethodInfo$1.doProceed(MethodInfo.java:279)[96:org.apache.camel.camel-core:2.16.0] > at > org.apache.camel.component.bean.MethodInfo$1.proceed(MethodInfo.java:252)[96:org.apache.camel.camel-core:2.16.0] > at > org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:177)[96:org.apache.camel.camel-core:2.16.0] > at > org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109)[96:org.apache.camel.camel-core:2.16.0] > at > org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:68)[96:org.apache.camel.camel-core:2.16.0] > at > org.apache.camel.component.bean.BeanProducer.process(BeanProducer.java:38)[96:org.apache.camel.camel-core:2.16.0] > at > org.apache.camel.processor.SendProcessor.process(SendProcessor.java:141)[96:org.apache.camel.camel-core:2.16.0] > at > org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)[96:org.apache.camel.camel-core:2.16.0] > at > org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:460)[96:org.apache.camel.camel-core:2.16.0] > at > org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:190)[96:org.apache.camel.camel-core:2.16.0] > at > org.apache.camel.processor.Pipeline.process(Pipeline.java:121)[96:org.apache.camel.camel-core:2.16.0] > at > org.apache.camel.processor.Pipeline.process(Pipeline.java:83)[96:org.apache.camel.camel-core:2.16.0] > at > org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:190)[96:org.apache.camel.camel-core:2.16.0] > at > org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:62)[96:org.apache.camel.camel-core:2.16.0] > at > org.apache.camel.processor.SendProcessor.process(SendProcessor.java:141)[96:org.apache.camel.camel-core:2.16.0] > at > org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)[96:org.apache.camel.camel-core:2.16.0] > at > org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:460)[96:org.apache.camel.camel-core:2.16.0] > at > org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:190)[96:org.apache.camel.camel-core:2.16.0] > at > org.apache.camel.processor.Pipeline.process(Pipeline.java:121)[96:org.apache.camel.camel-core:2.16.0] > at > org.apache.camel.processor.Pipeline.process(Pipeline.java:83)[96:org.apache.camel.camel-core:2.16.0] > at > org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:190)[96:org.apache.camel.camel-core:2.16.0] > at > org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109)[96:org.apache.camel.camel-core:2.16.0] > at > org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:87)[96:org.
How to configure a singleton ProducerTemplate bean with Spring JavaConfig
How to configure a singleton ProducerTemplate bean with Spring JavaConfig? I need to inject the ProducerTemplate bean into a Camel processor that is used by a Camel route configured also as a Spring singleton bean. -- View this message in context: http://camel.465427.n5.nabble.com/How-to-configure-a-singleton-ProducerTemplate-bean-with-Spring-JavaConfig-tp5769459.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: ProducerTemplate without using Spring
Hi Lucas, This is correct. Here is a unit test part of the camel project where you can see that we support 2 options (using @Produce annotation or @Inject @Uri) https://github.com/apache/camel/blob/master/components/camel-cdi/src/test/java/org/apache/camel/cdi/ProduceInjectTest.java https://github.com/apache/camel/blob/master/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/ProduceInjectedBean.java Regards, On Thu, Oct 16, 2014 at 8:25 PM, lucasweb lucas...@me.com wrote: I'm using the camel-cdi component to inject ProducerTemplates into my EJB's e.g. @Inject @Uri(jms:ToolQueue?preserveMessageQos=true) ProducerTemplate toolQueueMessageProducer; My understanding is that the camel-cdi component should manage the look up and lifecycle of the producer template for me. Is this correct? -- View this message in context: http://camel.465427.n5.nabble.com/ProducerTemplate-without-using-Spring-tp5739099p5757633.html Sent from the Camel - Users mailing list archive at Nabble.com. -- Charles Moulliard Apache Committer / Architect @RedHat Twitter : @cmoulliard | Blog : http://cmoulliard.github.io
Re: ProducerTemplate without using Spring
I'm using the camel-cdi component to inject ProducerTemplates into my EJB's e.g. @Inject @Uri(jms:ToolQueue?preserveMessageQos=true) ProducerTemplate toolQueueMessageProducer; My understanding is that the camel-cdi component should manage the look up and lifecycle of the producer template for me. Is this correct? -- View this message in context: http://camel.465427.n5.nabble.com/ProducerTemplate-without-using-Spring-tp5739099p5757633.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Handling ProducerTemplate Timeout + EJB
Hi Willem Jiang, First of all thanks a lot for your reply and which gave me some insight on ProducerTemplate threads in waiting state. I have one more issue. I am invoking an EJB which is deployed in Jboss jboss-as-7.1.1.Final. Below is piece of code i am using to invoke and EJB. private void sendRequest() { String camelID = jbossejb; Exchange furExchange = null; Message msg = null; final Employee employee = new Employee(); ProducerTemplate pProducerTemplate = getProducerTemplate(); Endpoint endPoint = springCamelContext.getEndpoint(jbossejb); FutureExchange futurexchange = (FutureExchange) pProducerTemplate .asyncSend(endPoint, new Processor() { public void process(Exchange exchange) throws Exception { exchange.getIn().setBody(employee); } }); System.out.println(futurexchange: + futurexchange); try { furExchange = futurexchange.get(15000, TimeUnit.SECONDS); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ExecutionException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (TimeoutException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (furExchange.getException() == null) { msg = furExchange.getOut(); String messageId = furExchange.getIn().getMessageId(); System.out.println(In Camel MessageID -: + messageId); msg = furExchange.getOut(); System.out.println(Message: + msg); } else { Exception ex = furExchange.getException(); ex.printStackTrace(); } } JNDI details are below bean id=ejb class=org.apache.camel.component.ejb.EjbComponent property name=properties ref=jndiProperties / /bean util:properties id=jndiProperties prop key=java.naming.factory.initialorg.jboss.naming.remote.client.InitialContextFactory/prop prop key=java.naming.provider.urlremote://localhost:4447/prop prop key=jboss.naming.client.ejb.contexttrue/prop prop key=java.naming.security.principaljboss7/prop prop key=java.naming.security.credentialspassword/prop /util:properties Exception java.lang.IllegalStateException is thrown with the stack trace below java.lang.IllegalStateException: No EJB receiver available for handling [appName:,modulename:MappedEJBModule,distinctname:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@508894e3 at org.jboss.ejb.client.EJBClientContext.requireEJBReceiver(EJBClientContext.java:584) at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:119) at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181) at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:136) at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:121) at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:104) at com.sun.proxy.$Proxy35.receiveEmployee(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.apache.camel.component.bean.MethodInfo.invoke(MethodInfo.java:407) at org.apache.camel.component.bean.MethodInfo$1.doProceed(MethodInfo.java:278) at org.apache.camel.component.bean.MethodInfo$1.proceed(MethodInfo.java:251) at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:166) at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:105) at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:67) at org.apache.camel.impl.ProcessorEndpoint.onExchange(ProcessorEndpoint.java:103) at org.apache.camel.impl.ProcessorEndpoint$1.process(ProcessorEndpoint.java:71) at org.apache.camel.util.AsyncProcessorConverterHelper
ProducerTemplate null when used to construct bean in new JndiContext in a unit test
I am trying to unit test a route that uses bean to dynamically construct an sftp endpoint. This works when I run my route in a normal context, as it seems a template is already in the registry and can be correctly injected. My problem is when trying to construct the unit test I seem to be running into a condition where the ProducerTemplate is still null when createJndiContext is invoked and that results in an NPE in my bean that need to call a method on the template. Any help would be greatly appreciated. Here is a simplified unit test that illustrates this: public class BeanWithProdTemplateDependencyTest extends CamelTestSupport { private static final Logger log = LoggerFactory.getLogger(BeanWithProdTemplateDependencyTest.class); private static final String FROM = direct:start; @EndpointInject(uri = mock:result) protected MockEndpoint resultEndpoint; @Before public void setUp() throws Exception { super.setUp(); context.getRouteDefinition(my-cool-route).adviceWith(context, new AdviceWithRouteBuilder() { @Override public void configure() throws Exception { replaceFromWith(FROM); } }); startCamelContext(); } @Test public void test() { template.sendBody(FROM, cheese); } @Override public boolean isUseAdviceWith() { return true; } @Override protected Context createJndiContext() throws Exception { JndiContext context = new JndiContext(); MyBean myBean = new MyBean(template); context.bind(myBean, myBean); return context; } @Override protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { @Override public void configure() throws Exception { from(jms:queue:inbox) .routeId(my-cool-route) .beanRef(myBean, doStuff) .log(Body: $body}) .to(mock:result); } }; } public class MyBean { private final ProducerTemplate producerTemplate; public MyBean(ProducerTemplate template) { this.producerTemplate = template; } public void doStuff() throws Exception{ // NPE here, template is null this.producerTemplate.sendBody(seda:foo, beer); } } } -- View this message in context: http://camel.465427.n5.nabble.com/ProducerTemplate-null-when-used-to-construct-bean-in-new-JndiContext-in-a-unit-test-tp5756543.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: ProducerTemplate null when used to construct bean in new JndiContext in a unit test
I figured it out. My answer can be found here: http://stackoverflow.com/questions/25851033/producertemplate-null-when-used-to-construct-bean-in-new-jndicontext-in-a-unit-t http://stackoverflow.com/questions/25851033/producertemplate-null-when-used-to-construct-bean-in-new-jndicontext-in-a-unit-t -- View this message in context: http://camel.465427.n5.nabble.com/ProducerTemplate-null-when-used-to-construct-bean-in-new-JndiContext-in-a-unit-test-tp5756543p5756551.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Camel 2.12.1 : How to send Http post with an attachment using ProducerTemplate
I have tried your suggestion and it works. Thanks! Shing On Monday, 16 June 2014, 3:10, Willem Jiang willem.ji...@gmail.com wrote: camel-http component support to send RequestEntity by default. If you want to send a file as a multi part form, you can just put the MultipartRequestEntity instance into the message body, just like this. private RequestEntity createMultipartRequestEntity() throws Exception { File file = new File(src/main/resources/META-INF/NOTICE.txt); Part[] parts = {new StringPart(comment, A binary file of some kind), new FilePart(file.getName(), file)}; return new MultipartRequestEntity(parts, new HttpMethodParams()); } @Test public void testSendMultiPartFormFromCamelHttpComponnent() throws Exception { String result = template.requestBody(http://localhost:; + getPort() + /test, createMultipartRequestEntity(), String.class); assertEquals(Get a wrong result, A binary file of some kind, result); } -- Willem Jiang Red Hat, Inc. Web: http://www.redhat.com Blog: http://willemjiang.blogspot.com (English) http://jnn.iteye.com (Chinese) Twitter: willemjiang Weibo: 姜宁willem On June 15, 2014 at 5:16:22 PM, Shing Hing Man (mat...@yahoo.com.invalid) wrote: Thanks for the link ! I found an example in https://github.com/apache/camel/blob/master/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpSendFileTest.java I have noticed from the example https://github.com/apache/camel/blob/master/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MultiPartFormTest.java that, Apache HttpClient is used to send a MultiPartForm. It looks as though one can not send a MultiPartForm (with more than one body parts) using Camel ProducerTemplate. Shing On Friday, 13 June 2014, 7:16, Claus Ibsen wrote: Hi A good idea is to check the unit tests of the components. Maybe you can find some sample code there. For http try look in https://github.com/apache/camel/tree/master/components/camel-http/src/test/java/org/apache/camel/component/http and https://github.com/apache/camel/tree/master/components/camel-jetty/src/test/java/org/apache/camel/component/jetty On Thu, Jun 12, 2014 at 9:07 PM, Shing Hing Man wrote: Hi, I tried to use producerTemplate to send a http post with an attached file. ProducerTemplate template = context.createProducerTemplate(); Exchange exchange = template.send(http://localhost:8080/file;, new Processor() { public void process(Exchange exchange) throws Exception { Message msgIn = exchange.getIn(); String userHome=System.getProperty(user.home); File file = new File(userHome + /test.txt); DataHandler dh = new DataHandler(new FileDataSource(file)); msgIn.addAttachment(myFile,dh); msgIn.setHeader(Exchange.CONTENT_TYPE, multipart/form-data); msgIn.setHeader(Exchange.HTTP_METHOD, POST); } }); At the server side, I received something like : RequestContext(HttpRequest(POST,http://localhost:8080/file,List(Content-Length: 0, Host: localhost:8080, User-Agent: Jakarta Commons-HttpClient/3.1, breadcrumbId: ID-gauss-site-41171-1402599541172-0-1),Empty,HTTP/1.1),Actor[akka://default/temp/$a],) The Context type and the attached file seem not to have reached the server. Is the above a correct way to send http post with attachment ? Thanks in advance for any assistance ! Shing -- Claus Ibsen - Red Hat, Inc. Email: cib...@redhat.com Twitter: davsclaus Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen hawtio: http://hawt.io/ fabric8: http://fabric8.io/
Re: Camel 2.12.1 : How to send Http post with an attachment using ProducerTemplate
Thanks for the link ! I found an example in https://github.com/apache/camel/blob/master/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpSendFileTest.java I have noticed from the example https://github.com/apache/camel/blob/master/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MultiPartFormTest.java that, Apache HttpClient is used to send a MultiPartForm. It looks as though one can not send a MultiPartForm (with more than one body parts) using Camel ProducerTemplate. Shing On Friday, 13 June 2014, 7:16, Claus Ibsen claus.ib...@gmail.com wrote: Hi A good idea is to check the unit tests of the components. Maybe you can find some sample code there. For http try look in https://github.com/apache/camel/tree/master/components/camel-http/src/test/java/org/apache/camel/component/http and https://github.com/apache/camel/tree/master/components/camel-jetty/src/test/java/org/apache/camel/component/jetty On Thu, Jun 12, 2014 at 9:07 PM, Shing Hing Man mat...@yahoo.com.invalid wrote: Hi, I tried to use producerTemplate to send a http post with an attached file. ProducerTemplate template = context.createProducerTemplate(); Exchange exchange = template.send(http://localhost:8080/file;, new Processor() { public void process(Exchange exchange) throws Exception { Message msgIn = exchange.getIn(); String userHome=System.getProperty(user.home); File file = new File(userHome + /test.txt); DataHandler dh = new DataHandler(new FileDataSource(file)); msgIn.addAttachment(myFile,dh); msgIn.setHeader(Exchange.CONTENT_TYPE, multipart/form-data); msgIn.setHeader(Exchange.HTTP_METHOD, POST); } }); At the server side, I received something like : RequestContext(HttpRequest(POST,http://localhost:8080/file,List(Content-Length: 0, Host: localhost:8080, User-Agent: Jakarta Commons-HttpClient/3.1, breadcrumbId: ID-gauss-site-41171-1402599541172-0-1),Empty,HTTP/1.1),Actor[akka://default/temp/$a],) The Context type and the attached file seem not to have reached the server. Is the above a correct way to send http post with attachment ? Thanks in advance for any assistance ! Shing -- Claus Ibsen - Red Hat, Inc. Email: cib...@redhat.com Twitter: davsclaus Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen hawtio: http://hawt.io/ fabric8: http://fabric8.io/
Re: Camel 2.12.1 : How to send Http post with an attachment using ProducerTemplate
camel-http component support to send RequestEntity by default. If you want to send a file as a multi part form, you can just put the MultipartRequestEntity instance into the message body, just like this. private RequestEntity createMultipartRequestEntity() throws Exception { File file = new File(src/main/resources/META-INF/NOTICE.txt); Part[] parts = {new StringPart(comment, A binary file of some kind), new FilePart(file.getName(), file)}; return new MultipartRequestEntity(parts, new HttpMethodParams()); } @Test public void testSendMultiPartFormFromCamelHttpComponnent() throws Exception { String result = template.requestBody(http://localhost:; + getPort() + /test, createMultipartRequestEntity(), String.class); assertEquals(Get a wrong result, A binary file of some kind, result); } -- Willem Jiang Red Hat, Inc. Web: http://www.redhat.com Blog: http://willemjiang.blogspot.com (English) http://jnn.iteye.com (Chinese) Twitter: willemjiang Weibo: 姜宁willem On June 15, 2014 at 5:16:22 PM, Shing Hing Man (mat...@yahoo.com.invalid) wrote: Thanks for the link ! I found an example in https://github.com/apache/camel/blob/master/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpSendFileTest.java I have noticed from the example https://github.com/apache/camel/blob/master/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MultiPartFormTest.java that, Apache HttpClient is used to send a MultiPartForm. It looks as though one can not send a MultiPartForm (with more than one body parts) using Camel ProducerTemplate. Shing On Friday, 13 June 2014, 7:16, Claus Ibsen wrote: Hi A good idea is to check the unit tests of the components. Maybe you can find some sample code there. For http try look in https://github.com/apache/camel/tree/master/components/camel-http/src/test/java/org/apache/camel/component/http and https://github.com/apache/camel/tree/master/components/camel-jetty/src/test/java/org/apache/camel/component/jetty On Thu, Jun 12, 2014 at 9:07 PM, Shing Hing Man wrote: Hi, I tried to use producerTemplate to send a http post with an attached file. ProducerTemplate template = context.createProducerTemplate(); Exchange exchange = template.send(http://localhost:8080/file;, new Processor() { public void process(Exchange exchange) throws Exception { Message msgIn = exchange.getIn(); String userHome=System.getProperty(user.home); File file = new File(userHome + /test.txt); DataHandler dh = new DataHandler(new FileDataSource(file)); msgIn.addAttachment(myFile,dh); msgIn.setHeader(Exchange.CONTENT_TYPE, multipart/form-data); msgIn.setHeader(Exchange.HTTP_METHOD, POST); } }); At the server side, I received something like : RequestContext(HttpRequest(POST,http://localhost:8080/file,List(Content-Length: 0, Host: localhost:8080, User-Agent: Jakarta Commons-HttpClient/3.1, breadcrumbId: ID-gauss-site-41171-1402599541172-0-1),Empty,HTTP/1.1),Actor[akka://default/temp/$a],) The Context type and the attached file seem not to have reached the server. Is the above a correct way to send http post with attachment ? Thanks in advance for any assistance ! Shing -- Claus Ibsen - Red Hat, Inc. Email: cib...@redhat.com Twitter: davsclaus Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen hawtio: http://hawt.io/ fabric8: http://fabric8.io/
Re: Camel 2.12.1 : How to send Http post with an attachment using ProducerTemplate
Hi A good idea is to check the unit tests of the components. Maybe you can find some sample code there. For http try look in https://github.com/apache/camel/tree/master/components/camel-http/src/test/java/org/apache/camel/component/http and https://github.com/apache/camel/tree/master/components/camel-jetty/src/test/java/org/apache/camel/component/jetty On Thu, Jun 12, 2014 at 9:07 PM, Shing Hing Man mat...@yahoo.com.invalid wrote: Hi, I tried to use producerTemplate to send a http post with an attached file. ProducerTemplate template = context.createProducerTemplate(); Exchange exchange = template.send(http://localhost:8080/file;, new Processor() { public void process(Exchange exchange) throws Exception { Message msgIn = exchange.getIn(); String userHome=System.getProperty(user.home); File file = new File(userHome + /test.txt); DataHandler dh = new DataHandler(new FileDataSource(file)); msgIn.addAttachment(myFile,dh); msgIn.setHeader(Exchange.CONTENT_TYPE, multipart/form-data); msgIn.setHeader(Exchange.HTTP_METHOD, POST); } }); At the server side, I received something like : RequestContext(HttpRequest(POST,http://localhost:8080/file,List(Content-Length: 0, Host: localhost:8080, User-Agent: Jakarta Commons-HttpClient/3.1, breadcrumbId: ID-gauss-site-41171-1402599541172-0-1),Empty,HTTP/1.1),Actor[akka://default/temp/$a],) The Context type and the attached file seem not to have reached the server. Is the above a correct way to send http post with attachment ? Thanks in advance for any assistance ! Shing -- Claus Ibsen - Red Hat, Inc. Email: cib...@redhat.com Twitter: davsclaus Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen hawtio: http://hawt.io/ fabric8: http://fabric8.io/
Camel 2.12.1 : How to send Http post with an attachment using ProducerTemplate
Hi, I tried to use producerTemplate to send a http post with an attached file. ProducerTemplate template = context.createProducerTemplate(); Exchange exchange = template.send(http://localhost:8080/file;, new Processor() { public void process(Exchange exchange) throws Exception { Message msgIn = exchange.getIn(); String userHome=System.getProperty(user.home); File file = new File(userHome + /test.txt); DataHandler dh = new DataHandler(new FileDataSource(file)); msgIn.addAttachment(myFile,dh); msgIn.setHeader(Exchange.CONTENT_TYPE, multipart/form-data); msgIn.setHeader(Exchange.HTTP_METHOD, POST); } }); At the server side, I received something like : RequestContext(HttpRequest(POST,http://localhost:8080/file,List(Content-Length: 0, Host: localhost:8080, User-Agent: Jakarta Commons-HttpClient/3.1, breadcrumbId: ID-gauss-site-41171-1402599541172-0-1),Empty,HTTP/1.1),Actor[akka://default/temp/$a],) The Context type and the attached file seem not to have reached the server. Is the above a correct way to send http post with attachment ? Thanks in advance for any assistance ! Shing
Re: ProducerTemplate creates too much threads
Thanks. -- View this message in context: http://camel.465427.n5.nabble.com/ProducerTemplate-creates-too-much-threads-tp5751299p5751438.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: ProducerTemplate creates too much threads
Thanks for your reply Willem. It was good to know about the configuring the cache. But are you sure this is the answer to my question about the threads? Elena -- View this message in context: http://camel.465427.n5.nabble.com/ProducerTemplate-creates-too-much-threads-tp5751299p5751361.html Sent from the Camel - Users mailing list archive at Nabble.com.