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 <reto.pe...@advanceit.ch> 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 <claus.ib...@gmail.com> > 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 <reto.pe...@advanceit.ch> > 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