Hi Claus, Is there a way to handle the RejectedExecutionException when using a DynamicRouter? I'm not quite ready yet to refactor my router to static endpoints. Here is the setup I have for it:
public void configure() throws Exception { from(inputEndpoint) .process(this::process) .onException(RejectedExecutionException.class).to(rejectedExecutionQueue) //does nothing unfortunately .dynamicRouter(new Expression() { @SuppressWarnings("unchecked") @Override public <T> T evaluate(final Exchange exchange, final Class<T> type) { // we need to call getRoutes only once if (exchange.getProperty("invoked") != null) { return null; } exchange.setProperty("invoked", true); // get request type from header String requestType = (String) exchange.getIn().getHeader("requesttype"); String[] routes = getRoutes(requestType); logger.info("For requestType '" + requestType + "' found following routes: " + Arrays.toString(routes)); return (T) routes; } }); } As you can see I'm not limited to just one possible route in the output of getRoutes. At the moment it's a max of two but it won't stay that way for long. This allows me to send an email or an SMS or both depending on the 'requesttype' header. I'm using the RabbitMQ component but the code is very similar there to the JMS component. The other places where I've seen this exception have me messing with the ProducerTemplate directly (not doing that again!). How are static endpoints handling the startup process differently to dynamic ones? Is there something that can be added to the DynamicRouter to behave in a similar fashion? I don't mind getting my hands dirty for it, just would need some guidance on it. Thanks, Valdis -----Original Message----- From: Claus Ibsen [mailto:claus.ib...@gmail.com] Sent: 14 June 2019 08:07 To: users@camel.apache.org Subject: Re: Intermittent RejectedExecutionException Hi No I am saying that you setup the endpoint as if it was static, but you override the destination via a special Camel header you set before from setHeader to Then you can simulate dynamic to. And in this case its actaully better because you have 1 endpoint, instead of N endpoints where each take some overhead compared to just 1, and therefore also they dont need to be started as the 1 is already started. On Thu, Jun 13, 2019 at 7:54 PM Michael Davis <michael.da...@solace.com> wrote: > > Thanks for the quick reply, Claus! > > My understanding is that we’d have to then configure the to: endpoint with a > static topic – all the messages coming out of the producer would have to have > the same topic, right? > > Can we say that this is a known issue in Camel, and that my client is not > doing anything wrong? > > Regards, > Michael > > From: Claus Ibsen <claus.ib...@gmail.com> > Sent: Thursday, June 13, 2019 1:13 PM > To: users@camel.apache.org > Subject: Re: Intermittent RejectedExecutionException > > Hi > > I would try with just <to> and set a header with the dynamic > destination (CamelJmsDestinationOverride) or something like that, > check the docs/source code, then you use a static sender. > > On Thu, Jun 13, 2019 at 6:57 PM Michael Davis > <michael.da...@solace.com<mailto:michael.da...@solace.com>> wrote: > > > > Hi, > > > > I'm running Camel version 2.24.0, I saw the same issue with 2.23.x. > > > > I've got a route that connects two JMS systems. The Producer is configured > > with a dynamic to: > > > > <c:from uri="tibco:topic:PAR.*.FX.DATA.>"/> > > <c:toD > > uri="solace-jms:topic:${header.jmsDestination.topicName.replace('.', > > '/')}" /> > > > > Sometimes, but not always, we get this error on startup: > > > > java.util.concurrent.RejectedExecutionException: null at > > org.apache.camel.component.jms.JmsProducer.process(JmsProducer.java: > > 144) ~[camel-jms-2.23.1.jar!/:2.23.1] at > > org.apache.camel.processor.SendDynamicProcessor$1.doInAsyncProducer( > > SendDynamicProcessor.java:178) ~[camel-core-2.23.1.jar!/:2.23.1] at > > org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache. > > java:445) ~[camel-core-2.23.1.jar!/:2.23.1] at > > org.apache.camel.processor.SendDynamicProcessor.process(SendDynamicP > > rocessor.java:160) ~[camel-core-2.23.1.jar!/:2.23.1] at > > org.apache.camel.processor.RedeliveryErrorHandler.process(Redelivery > > ErrorHandler.java:548) [camel-core-2.23.1.jar!/:2.23.1] at > > org.apache.camel.processor.CamelInternalProcessor.process(CamelInter > > nalProcessor.java:201) [camel-core-2.23.1.jar!/:2.23.1] at > > org.apache.camel.processor.Pipeline.process(Pipeline.java:138) > > [camel-core-2.23.1.jar!/:2.23.1] at > > org.apache.camel.processor.Pipeline.process(Pipeline.java:101) > > [camel-core-2.23.1.jar!/:2.23.1] at > > org.apache.camel.processor.CamelInternalProcessor.process(CamelInter > > nalProcessor.java:201) [camel-core-2.23.1.jar!/:2.23.1] at > > org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAs > > yncProcessor.java:97) [camel-core-2.23.1.jar!/:2.23.1] at > > org.apache.camel.component.jms.EndpointMessageListener.onMessage(End > > pointMessageListener.java:113) [camel-jms-2.23.1.jar!/:2.23.1] > > > > This seems to happen when messages are coming in before the producer is > > fully initialized. If I wait until Camel starts before I start the message > > flow, everything works fine. > > > > I'm not the only one to see this problem. Someone else reported the same > > thing, the stack trace is almost identical (line numbers are a bit > > different because it's a different version: > > > > https://scanmail.trustwave.com/?c=17268&d=lceD3YWHFCubnxIaZ9HGIe9Hwq > > gEjpB_nuK_Sk0ZSw&s=33&u=https%3a%2f%2fgithub%2ecom%2fcamelinaction%2 > > fcamelinaction2%2fissues%2f18<https://scanmail.trustwave.com/?c=1726 > > 8&d=lceD3YWHFCubnxIaZ9HGIe9HwqgEjpB_nuK_Sk0ZSw&s=33&u=https%3a%2f%2f > > github%2ecom%2fcamelinaction%2fcamelinaction2%2fissues%2f18> > > > > Has anyone else seen this? Does anyone know how to fix it? > > > > Thanks > > Michael Davis > > Ottawa > > > > > -- > Claus Ibsen > ----------------- > http://scanmail.trustwave.com/?c=17268&d=lceD3YWHFCubnxIaZ9HGIe9HwqgEj > pB_nrexTxEaGw&s=33&u=http%3a%2f%2fdavsclaus%2ecom<http://scanmail.trus > twave.com/?c=17268&d=lceD3YWHFCubnxIaZ9HGIe9HwqgEjpB_nrexTxEaGw&s=33&u > =http%3a%2f%2fdavsclaus%2ecom> @davsclaus Camel in Action 2: > https://scanmail.trustwave.com/?c=17268&d=lceD3YWHFCubnxIaZ9HGIe9HwqgE > jpB_nri_GhtMSA&s=33&u=https%3a%2f%2fwww%2emanning%2ecom%2fibsen2<https > ://scanmail.trustwave.com/?c=17268&d=lceD3YWHFCubnxIaZ9HGIe9HwqgEjpB_n > ri_GhtMSA&s=33&u=https%3a%2f%2fwww%2emanning%2ecom%2fibsen2> -- Claus Ibsen ----------------- http://scanmail.trustwave.com/?c=17268&d=lceD3YWHFCubnxIaZ9HGIe9HwqgEjpB_nrexTxEaGw&s=33&u=http%3a%2f%2fdavsclaus%2ecom @davsclaus Camel in Action 2: https://scanmail.trustwave.com/?c=17268&d=lceD3YWHFCubnxIaZ9HGIe9HwqgEjpB_nri_GhtMSA&s=33&u=https%3a%2f%2fwww%2emanning%2ecom%2fibsen2 Vhi Group DAC (Vhi) is a holding company for insurance and healthcare services, which include Vhi Healthcare DAC, Vhi Insurance DAC, Vhi Health Services DAC and Vhi Investments DAC. Vhi Healthcare DAC trading as Vhi Healthcare and Vhi Insurance DAC trading as Vhi Insurance are regulated by the Central Bank of Ireland. Vhi Healthcare is tied to Vhi Insurance DAC for health insurance in Ireland which is underwritten by Vhi Insurance DAC. Vhi Healthcare is tied to Zurich Life Assurance plc for Vhi Life Term Insurance and Vhi Mortgage Protection which are underwritten by Zurich Life Assurance plc. Vhi Healthcare is tied to Collinson Insurance Solutions Europe Limited for MultiTrip Travel Insurance and Vhi Dental Insurance which are underwritten by Great Lakes Insurance SE and for Vhi International Health Insurance which is underwritten by Collinson Insurance Europe Limited. For more information about the Vhi Group please go to: https://www.vhi.ie/about-vhi. Tá Vhi Group DAC (Vhi) ina chuideachta sealbhaíochta le haghaidh seirbhísí árachais agus seirbhísí cúram sláinte, lena n-áirítear Vhi Healthcare DAC, Vhi Insurance DAC, Vhi Health Services DAC agus Vhi Investments DAC. Déanann Banc Ceannais na hÉireann rialáil ar Vhi Healthcare DAC, ag trádáil dó mar Vhi Healthcare, agus ar Vhi Insurance DAC, ag trádáil dó mar Vhi Insurance. Tá Vhi Healthcare ceangailte le Vhi Insurance DAC le haghaidh árachas sláinte in Éirinn, rud atá frithgheallta ag Vhi Insurance DAC. Tá Vhi Healthcare ceangailte le Zurich Life Assurance plc le haghaidh Árachais Saoil de chuid Vhi agus Árachas Cosanta Morgáiste de chuid Vhi atá frithgheallta ag Zurich Life Assurance plc. Tá Vhi Healthcare ceangailte le Collinson Insurance Solutions Europe Limited le haghaidh Árachas Taistil Ilturais agus Árachas Fiaclóireachta de chuid Vhi atá frithgheallta ag Great Lakes Insurance SE agus le haghaidh Árachas Sláinte Idirnáisiúnta de chuid Vhi atá frithgheallta ag Collinson Insurance Europe Limited. Chun tuilleadh faisnéise a fháil faoi Ghrúpa Vhi, tabhair cuairt ar: https://www.vhi.ie/about-vhi. This e-mail and any files transmitted with it contain information which may be confidential and which may also be privileged and is intended solely for the use of the individual or entity to whom it is addressed. Unless you are the intended recipient you may not copy or use it, or disclose it to anyone else. Any opinions expressed are that of the individual and not necessarily that of the Vhi Group. If you have received this e-mail in error please notify the sender by return.