Return-Path: X-Original-To: apmail-camel-users-archive@www.apache.org Delivered-To: apmail-camel-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 53987189C1 for ; Wed, 23 Dec 2015 08:50:27 +0000 (UTC) Received: (qmail 88089 invoked by uid 500); 23 Dec 2015 08:50:21 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 88040 invoked by uid 500); 23 Dec 2015 08:50:21 -0000 Mailing-List: contact users-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@camel.apache.org Delivered-To: mailing list users@camel.apache.org Received: (qmail 88028 invoked by uid 99); 23 Dec 2015 08:50:21 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 Dec 2015 08:50:21 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 43A831804E5 for ; Wed, 23 Dec 2015 08:50:21 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 4.287 X-Spam-Level: **** X-Spam-Status: No, score=4.287 tagged_above=-999 required=6.31 tests=[DKIM_ADSP_CUSTOM_MED=0.001, KAM_ASCII_DIVIDERS=0.8, NML_ADSP_CUSTOM_MED=1.2, SPF_SOFTFAIL=0.972, URIBL_BLOCKED=0.001, URI_HEX=1.313] autolearn=disabled Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id HmFajQGRx014 for ; Wed, 23 Dec 2015 08:50:12 +0000 (UTC) Received: from mwork.nabble.com (mwork.nabble.com [162.253.133.43]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with ESMTP id 0790520FD2 for ; Wed, 23 Dec 2015 08:50:12 +0000 (UTC) Received: from msam.nabble.com (unknown [162.253.133.85]) by mwork.nabble.com (Postfix) with ESMTP id 3AB1B6E695F3 for ; Wed, 23 Dec 2015 00:48:21 -0800 (PST) Date: Wed, 23 Dec 2015 01:50:11 -0700 (MST) From: ghoshp29 To: users@camel.apache.org Message-ID: <1450860611333-5775388.post@n5.nabble.com> Subject: Unable to resolve named parameter in camel route MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi, I am using camel 2.15 and java 1.7 for my enterprise application. Our database is postgresql 9.4.0. I am trying to configure camel route for a scenario where my requirement is to read data from one postgresql schema(present in one database) with a select query and insert the same data into another postgresql schema(present in another database). I have used below syntax for doing two queries in a single transaction. from("timer://foo?period="+serverData.getTimer()).threads(serverData.getNumberOfInstances()).setBody(constant(serverData.getSql())). to("jdbc:" + serverData.getUrl() + serverData.getUserId()).setBody(constant("insert into new_raw_table_test (numbersubscribers, id) values(:?numbersubscribers, :?id)")). to("jdbc:" + serverData.getUrl() + serverData.getUserId()+"?allowNamedParameters=true&outputType=SelectOne&useHeadersAsParameters=true&resetAutoCommit=false"); process(custom application logic); Note - In the above syntax, serverData class is used to get the postgresql connection details and sql details. I am facing camel exception where camel is unable to resolve the name parameter. Below are my stack trace for reference. 15/12/23 14:08:28 ERROR processor.DefaultErrorHandler: Failed delivery for (MessageId: ID-5CG4525D29-53920-1450859904799-0-3 on ExchangeId: ID-5CG4525D29-53920-1450859904799-0-2). Exhausted after delivery attempt: 1 caught: org.apache.camel.RuntimeExchangeException: Cannot find key [numbersubscribers] in message body or headers to use when setting named parameter in query [insert into new_raw_table_test (numbersubscribers, id) values(:?numbersubscribers, :?id)] on the exchange: Exchange[Message: insert into new_raw_table_test (numbersubscribers, id) values(:?numbersubscribers, :?id)] Message History --------------------------------------------------------------------------------------------------------------------------------------- RouteId ProcessorId Processor Elapsed (ms) [route1 ] [route1 ] [timer://foo?period=15000 ] [ 131] [route1 ] [threads1 ] [threads ] [ 131] [route1 ] [setBody1 ] [setBody[{select numbersubscribers, id from performance_adapter_test}] ] [ 0] [route1 ] [to1 ] [jdbc:jdbc:postgresql://127.0.0.1:5432/postgrespostgres ] [ 111] [route1 ] [setBody2 ] [setBody[{insert into new_raw_table_test (numbersubscribers, id) values(:?numbe] [ 0] [route1 ] [to2 ] [jdbc:jdbc:postgresql://127.0.0.1:5432/postgrespostgres?allowNamedParameters=tr] [ 0] Exchange --------------------------------------------------------------------------------------------------------------------------------------- Exchange[ Id ID-5CG4525D29-53920-1450859904799-0-2 ExchangePattern InOnly Headers {breadcrumbId=ID-5CG4525D29-53920-1450859904799-0-1, *CamelJdbcColumnNames=[numbersubscribers, id]*, CamelJdbcRowCount=2, CamelRedelivered=false, CamelRedeliveryCounter=0, firedTime=Wed Dec 23 14:08:28 IST 2015} BodyType String Body insert into new_raw_table_test (numbersubscribers, id) values(:?numbersubscribers, :?id) ] Stacktrace --------------------------------------------------------------------------------------------------------------------------------------- org.apache.camel.RuntimeExchangeException: Cannot find key [numbersubscribers] in message body or headers to use when setting named parameter in query [insert into new_raw_table_test (numbersubscribers, id) values(:?numbersubscribers, :?id)] on the exchange: Exchange[Message: *insert into new_raw_table_test (numbersubscribers, id) values(:?numbersubscribers, :?id)*] at org.apache.camel.component.jdbc.DefaultJdbcPrepareStatementStrategy$1.next(DefaultJdbcPrepareStatementStrategy.java:99) at org.apache.camel.component.jdbc.DefaultJdbcPrepareStatementStrategy$1.hasNext(DefaultJdbcPrepareStatementStrategy.java:83) at org.apache.camel.component.jdbc.DefaultJdbcPrepareStatementStrategy.populateStatement(DefaultJdbcPrepareStatementStrategy.java:128) at org.apache.camel.component.jdbc.JdbcProducer.doCreateAndExecuteSqlStatementWithHeaders(JdbcProducer.java:133) at org.apache.camel.component.jdbc.JdbcProducer.createAndExecuteSqlStatement(JdbcProducer.java:116) at org.apache.camel.component.jdbc.JdbcProducer.processingSqlWithoutSettingAutoCommit(JdbcProducer.java:108) at org.apache.camel.component.jdbc.JdbcProducer.process(JdbcProducer.java:68) at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61) at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:129) at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77) at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:448) at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191) at org.apache.camel.processor.Pipeline.process(Pipeline.java:118) at org.apache.camel.processor.Pipeline.process(Pipeline.java:80) at org.apache.camel.processor.Pipeline.process(Pipeline.java:118) at org.apache.camel.processor.Pipeline.access$100(Pipeline.java:43) at org.apache.camel.processor.Pipeline$1.done(Pipeline.java:136) at org.apache.camel.processor.ThreadsProcessor$ProcessCall.run(ThreadsProcessor.java:83) at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) 15/12/23 14:08:28 WARN timer.TimerConsumer: Error processing exchange. Exchange[Message: insert into new_raw_table_test (numbersubscribers, id) values(:?numbersubscribers, :?id)]. Caused by: [org.apache.camel.RuntimeExchangeException - Cannot find key [numbersubscribers] in message body or headers to use when setting named parameter in query [insert into new_raw_table_test (numbersubscribers, id) values(:?numbersubscribers, :?id)] on the exchange: Exchange[Message: insert into new_raw_table_test (numbersubscribers, id) values(:?numbersubscribers, :?id)]] org.apache.camel.RuntimeExchangeException: Cannot find key [numbersubscribers] in message body or headers to use when setting named parameter in query [insert into new_raw_table_test (numbersubscribers, id) values(:?numbersubscribers, :?id)] on the exchange: Exchange[Message: insert into new_raw_table_test (numbersubscribers, id) values(:?numbersubscribers, :?id)] at org.apache.camel.component.jdbc.DefaultJdbcPrepareStatementStrategy$1.next(DefaultJdbcPrepareStatementStrategy.java:99) at org.apache.camel.component.jdbc.DefaultJdbcPrepareStatementStrategy$1.hasNext(DefaultJdbcPrepareStatementStrategy.java:83) at org.apache.camel.component.jdbc.DefaultJdbcPrepareStatementStrategy.populateStatement(DefaultJdbcPrepareStatementStrategy.java:128) at org.apache.camel.component.jdbc.JdbcProducer.doCreateAndExecuteSqlStatementWithHeaders(JdbcProducer.java:133) at org.apache.camel.component.jdbc.JdbcProducer.createAndExecuteSqlStatement(JdbcProducer.java:116) at org.apache.camel.component.jdbc.JdbcProducer.processingSqlWithoutSettingAutoCommit(JdbcProducer.java:108) at org.apache.camel.component.jdbc.JdbcProducer.process(JdbcProducer.java:68) at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61) at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:129) at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77) at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:448) at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191) at org.apache.camel.processor.Pipeline.process(Pipeline.java:118) at org.apache.camel.processor.Pipeline.process(Pipeline.java:80) at org.apache.camel.processor.Pipeline.process(Pipeline.java:118) at org.apache.camel.processor.Pipeline.access$100(Pipeline.java:43) at org.apache.camel.processor.Pipeline$1.done(Pipeline.java:136) at org.apache.camel.processor.ThreadsProcessor$ProcessCall.run(ThreadsProcessor.java:83) at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) I have highlighted two portion where we can see that camel can able to read the column names from select query but during insert operation it is unable to find/map the column name with the query. Would you kindly check and let me know if I am doing some mistake or is there any issue with camel named parameter resolution (though I know there is a jira ticket CAMEL-7983 for the same and it got resolved with camel 2.15). -- View this message in context: http://camel.465427.n5.nabble.com/Unable-to-resolve-named-parameter-in-camel-route-tp5775388.html Sent from the Camel - Users mailing list archive at Nabble.com.