Re: [SQL COMPONENTE] CamelSqlGeneratedKeyRows has a bug?

2015-01-09 Thread Grzegorz Grzybek
Hi Fabrizio

here's what is wrong with your example:
 - to uri=jdbc://mysql / means you're using JDBC component, not SQL
component
 - so you should use setHeader headerName=CamelRetrieveGeneratedKeys,
not setHeader headerName=CamelSqlRetrieveGeneratedKeys
 - you should also use
simple${in.headers.CamelGeneratedKeysRows}/simple, not
simple${out.header.CamelSqlGeneratedKeyRows}/simple because generated
keys stored in out are available in in of the next processor
 - add to uri=log:generated keys?showAll=trueamp;multiline=true /
after setBody to see:

[  qtp1540453036-19] generated keys INFO
Exchange[
...
*, Body: [{GENERATED_KEY=12}]*
...
]

regards
Grzegorz

2015-01-08 16:16 GMT+01:00 Claus Ibsen claus.ib...@gmail.com:

 Hi

 See this FAQ
 http://camel.apache.org/using-getin-or-getout-methods-on-exchange.html

 Rule of thumb, dont use out.

 On Thu, Jan 8, 2015 at 3:37 PM, fabrizio.spataro
 fabrizio.spat...@bizmate.it wrote:
  Hello,
 
  So.. is it a bug? I haven't any information about generated keys (OUT
  Message is null)
 
  this is my code:
 
  spring DSL
 
  camel:camelContext xmlns=http://camel.apache.org/schema/spring;
  camel:restConfiguration bindingMode=auto component=jetty
  host=0.0.0.0 port=8080/
camel:rest path=/api
   camel:get uri=/doIt produces=application/json
  camel:route
 setHeader headerName=CamelSqlRetrieveGeneratedKeys
  constanttrue/constant
 /setHeader
  setBody
  constant
 
  insert into company (id,
 name, description, email) values (0,
  'myName', '', 'he...@camel.com')
  /constant
  /setBody
  to uri=log:executing
 query?showAll=trueamp;multiline=true/
 
  to uri=jdbc://mysql /
 
  setBody
 
  simple${out.header.CamelSqlGeneratedKeyRows}/simple
  /setBody
/camel:route
   /camel:get
  /camel:rest
 
/camel:camelContext
 
  I had attach full example code package RetrieveGeneratedKey.zip
  
 http://camel.465427.n5.nabble.com/file/n5761460/RetrieveGeneratedKey.zip
 
 
 
  --
  View this message in context:
 http://camel.465427.n5.nabble.com/SQL-COMPONENT-CamelSqlGeneratedKeyRows-has-a-bug-tp5761113p5761460.html
  Sent from the Camel - Users mailing list archive at Nabble.com.



 --
 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: [SQL COMPONENTE] CamelSqlGeneratedKeyRows has a bug?

2015-01-09 Thread fabrizio.spataro
Of course! I never want to use out message but reading example code (posted
by Grzegorz Grzybek) i suppose that *CamelSqlGeneratedKeyRows * variable set
into it.

code:

// assertions of the response
assertNotNull(out);
assertNotNull(out.getOut());
assertNotNull(out.getOut().getHeader(SqlConstants.SQL_GENERATED_KEYS_DATA));

(source:
https://github.com/apache/camel/blob/camel-2.14.1/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlGeneratedKeysTest.java#L70-L97)

This variable is not present even into in message headers.

My attach code test what I'm saying. Can you run it?

Thnkx everyone!



--
View this message in context: 
http://camel.465427.n5.nabble.com/SQL-COMPONENT-CamelSqlGeneratedKeyRows-has-a-bug-tp5761113p5761506.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: [SQL COMPONENTE] CamelSqlGeneratedKeyRows has a bug?

2015-01-09 Thread Grzegorz Grzybek
Fabrizio

I've fixed your example. dont' use CamelSqlGeneratedKeyRows, use
CamelGeneratedKeyRows because you're using JdbcComponent, not
SqlComponent.
Plus - this test aserts availability of headers in out - right, but those
are copied to in of next (e.g. setBody) processor.

regards
Grzegorz

2015-01-09 9:40 GMT+01:00 fabrizio.spataro fabrizio.spat...@bizmate.it:

 Of course! I never want to use out message but reading example code (posted
 by Grzegorz Grzybek) i suppose that *CamelSqlGeneratedKeyRows * variable
 set
 into it.

 code:
 
 // assertions of the response
 assertNotNull(out);
 assertNotNull(out.getOut());

 assertNotNull(out.getOut().getHeader(SqlConstants.SQL_GENERATED_KEYS_DATA));
 
 (source:

 https://github.com/apache/camel/blob/camel-2.14.1/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlGeneratedKeysTest.java#L70-L97
 )

 This variable is not present even into in message headers.

 My attach code test what I'm saying. Can you run it?

 Thnkx everyone!



 --
 View this message in context:
 http://camel.465427.n5.nabble.com/SQL-COMPONENT-CamelSqlGeneratedKeyRows-has-a-bug-tp5761113p5761506.html
 Sent from the Camel - Users mailing list archive at Nabble.com.



Re: [SQL COMPONENTE] CamelSqlGeneratedKeyRows has a bug?

2015-01-09 Thread fabrizio.spataro
Thanks guy!

I finally solved my problem

King regards!



--
View this message in context: 
http://camel.465427.n5.nabble.com/SQL-COMPONENT-CamelSqlGeneratedKeyRows-has-a-bug-tp5761113p5761529.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: [SQL COMPONENTE] CamelSqlGeneratedKeyRows has a bug?

2015-01-08 Thread Grzegorz Grzybek
Hello Fabrizio

See this test case as an example of this feature:
https://github.com/apache/camel/blob/camel-2.14.1/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlGeneratedKeysTest.java#L70-L97

regards
Grzegorz Grzybek

2015-01-07 14:55 GMT+01:00 fabrizio.spataro fabrizio.spat...@bizmate.it:

 My camel version is 2.14.1



 --
 View this message in context:
 http://camel.465427.n5.nabble.com/SQL-COMPONENT-CamelSqlGeneratedKeyRows-has-a-bug-tp5761113p5761430.html
 Sent from the Camel - Users mailing list archive at Nabble.com.



Re: [SQL COMPONENTE] CamelSqlGeneratedKeyRows has a bug?

2015-01-08 Thread fabrizio.spataro
Hello,

So.. is it a bug? I haven't any information about generated keys (OUT
Message is null)

this is my code:

spring DSL

camel:camelContext xmlns=http://camel.apache.org/schema/spring;
camel:restConfiguration bindingMode=auto component=jetty
host=0.0.0.0 port=8080/
  camel:rest path=/api
 camel:get uri=/doIt produces=application/json
camel:route
   setHeader headerName=CamelSqlRetrieveGeneratedKeys
constanttrue/constant
   /setHeader
setBody
constant

insert into company (id, name, 
description, email) values (0,
'myName', '', 'he...@camel.com')
/constant
/setBody
to uri=log:executing 
query?showAll=trueamp;multiline=true/

to uri=jdbc://mysql /

setBody

simple${out.header.CamelSqlGeneratedKeyRows}/simple
/setBody
  /camel:route
 /camel:get
/camel:rest

  /camel:camelContext

I had attach full example code package RetrieveGeneratedKey.zip
http://camel.465427.n5.nabble.com/file/n5761460/RetrieveGeneratedKey.zip  



--
View this message in context: 
http://camel.465427.n5.nabble.com/SQL-COMPONENT-CamelSqlGeneratedKeyRows-has-a-bug-tp5761113p5761460.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: [SQL COMPONENTE] CamelSqlGeneratedKeyRows has a bug?

2015-01-08 Thread Claus Ibsen
Hi

See this FAQ
http://camel.apache.org/using-getin-or-getout-methods-on-exchange.html

Rule of thumb, dont use out.

On Thu, Jan 8, 2015 at 3:37 PM, fabrizio.spataro
fabrizio.spat...@bizmate.it wrote:
 Hello,

 So.. is it a bug? I haven't any information about generated keys (OUT
 Message is null)

 this is my code:

 spring DSL

 camel:camelContext xmlns=http://camel.apache.org/schema/spring;
 camel:restConfiguration bindingMode=auto component=jetty
 host=0.0.0.0 port=8080/
   camel:rest path=/api
  camel:get uri=/doIt produces=application/json
 camel:route
setHeader headerName=CamelSqlRetrieveGeneratedKeys
 constanttrue/constant
/setHeader
 setBody
 constant

 insert into company (id, 
 name, description, email) values (0,
 'myName', '', 'he...@camel.com')
 /constant
 /setBody
 to uri=log:executing 
 query?showAll=trueamp;multiline=true/

 to uri=jdbc://mysql /

 setBody
 
 simple${out.header.CamelSqlGeneratedKeyRows}/simple
 /setBody
   /camel:route
  /camel:get
 /camel:rest

   /camel:camelContext

 I had attach full example code package RetrieveGeneratedKey.zip
 http://camel.465427.n5.nabble.com/file/n5761460/RetrieveGeneratedKey.zip



 --
 View this message in context: 
 http://camel.465427.n5.nabble.com/SQL-COMPONENT-CamelSqlGeneratedKeyRows-has-a-bug-tp5761113p5761460.html
 Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
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: [SQL COMPONENTE] CamelSqlGeneratedKeyRows has a bug?

2014-12-30 Thread Christian Müller
Which Camel version do you use?

Best,

Christian
-

Software Integration Specialist

Apache Member
V.P. Apache Camel | Apache Camel PMC Member | Apache Camel committer
Apache Incubator PMC Member

https://www.linkedin.com/pub/christian-mueller/11/551/642

On Mon, Dec 29, 2014 at 12:28 PM, fabrizio.spataro 
fabrizio.spat...@bizmate.it wrote:

 Hello,

 i am using sql component with CamelSqlRetrieveGeneratedKeys=true but after
 an insert operation i don't have any CamelSqlGeneratedKeyRows header.

 Is it a bug?

 I am using mysql server 5.1.

 Tnkx



 --
 View this message in context:
 http://camel.465427.n5.nabble.com/SQL-COMPONENTE-CamelSqlGeneratedKeyRows-has-a-bug-tp5761113.html
 Sent from the Camel - Users mailing list archive at Nabble.com.