You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "jason.parr" <ja...@usa.net> on 2011/08/04 15:00:07 UTC

Problem binding multiple params to a bean

Hi,

Try as I might I can't bind a value associated with a header onto a bean
reference's second method argument. Null always gets passed to the second
argument on amendTrade(p1,p2). I can log the header value OK, the correct
method gets called but second argument is always null.

I've tried most of the various ways that a bean can be bound to all with the
same effect.

Route:

    from("direct:amend-bond-trade")
      .log("direct:amend-bond-trade")
      .to("log:showBody=false?showBodyType=true&showHeaders=true")
      .log("Header>>>> ${header.previousVersion}")
      .to("bean:radialTransformer?method=amendTrade(${body},
${header.previousVersion})")
     
.to("activemq:queue:nomura.fiet.stp.radial.trades?jmsMessageType=Map");

Log:

[1) thread #0 - file://src/data] route5                         INFO 
direct:amend-bond-trade
[1) thread #0 - file://src/data] showBody=false                 INFO 
Exchange[ExchangePattern:InOnly,
Headers:{previousVersion=com.nomura.fiet.stp.trademessage.BondTrade@a2d304,
tradeEventType=AMEND}, BodyType:com.nomura.fiet.stp.trademessage.BondTrade,
Body:com.nomura.fiet.stp.trademessage.BondTrade@14d659d]
[1) thread #0 - file://src/data] route5                         INFO 
Header>>>> com.nomura.fiet.stp.trademessage.BondTrade@a2d304
[1) thread #0 - file://src/data] route7                         INFO 
direct:error
[1) thread #0 - file://src/data] com                            ERROR
Exchange[Id:ID-LONWD030282-2387-1312460018181-0-8, ExchangePattern:InOnly,
Properties:{CamelToEndpoint=log://com?level=ERROR&showAll=true,
CamelBatchComplete=false, CamelBatchSize=3, CamelCreatedTimestamp=Thu Aug 04
13:13:40 BST 2011,
CamelFailureEndpoint=bean://radialTransformer?method=amendTrade%28%24%7Bbody%7D%2C+%24%7Bheader.previousVersion%7D%29,
CamelFileExchangeFile=GenericFile[msg2_bond_amend_10856546.xml],
CamelBatchIndex=1, CamelExceptionCaught=java.lang.IllegalArgumentException:
Args can't be null},
Headers:{previousVersion=com.nomura.fiet.stp.trademessage.BondTrade@a2d304,
tradeEventType=AMEND}, BodyType:com.nomura.fiet.stp.trademessage.BondTrade,
Body:com.nomura.fiet.stp.trademessage.BondTrade@14d659d,
CaughtExceptionType:java.lang.IllegalArgumentException,
CaughtExceptionMessage:Args can't be null,
StackTrace:java.lang.IllegalArgumentException: Args can't be null
	at
com.nomura.fiet.stp.radial.BondTradeRadialTransformer.amendTrade(BondTradeRadialTransformer.java:23)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)


--
View this message in context: http://camel.465427.n5.nabble.com/Problem-binding-multiple-params-to-a-bean-tp4666250p4666250.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Problem binding multiple params to a bean

Posted by "jason.parr" <ja...@usa.net>.
I was not using any camel annotations - trying to choose method just from
router builder config.

--
View this message in context: http://camel.465427.n5.nabble.com/Problem-binding-multiple-params-to-a-bean-tp4666250p4666409.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Problem binding multiple params to a bean

Posted by Zbarcea Hadrian <hz...@gmail.com>.
Jason,

How is your method defined? Are you using the @Body and @Header annotations?

Hadrian


On Aug 4, 2011, at 9:00 AM, jason.parr wrote:

> 
> Hi,
> 
> Try as I might I can't bind a value associated with a header onto a bean
> reference's second method argument. Null always gets passed to the second
> argument on amendTrade(p1,p2). I can log the header value OK, the correct
> method gets called but second argument is always null.
> 
> I've tried most of the various ways that a bean can be bound to all with the
> same effect.
> 
> Route:
> 
>    from("direct:amend-bond-trade")
>      .log("direct:amend-bond-trade")
>      .to("log:showBody=false?showBodyType=true&showHeaders=true")
>      .log("Header>>>> ${header.previousVersion}")
>      .to("bean:radialTransformer?method=amendTrade(${body},
> ${header.previousVersion})")
> 
> .to("activemq:queue:nomura.fiet.stp.radial.trades?jmsMessageType=Map");
> 
> Log:
> 
> [1) thread #0 - file://src/data] route5                         INFO 
> direct:amend-bond-trade
> [1) thread #0 - file://src/data] showBody=false                 INFO 
> Exchange[ExchangePattern:InOnly,
> Headers:{previousVersion=com.nomura.fiet.stp.trademessage.BondTrade@a2d304,
> tradeEventType=AMEND}, BodyType:com.nomura.fiet.stp.trademessage.BondTrade,
> Body:com.nomura.fiet.stp.trademessage.BondTrade@14d659d]
> [1) thread #0 - file://src/data] route5                         INFO 
> Header>>>> com.nomura.fiet.stp.trademessage.BondTrade@a2d304
> [1) thread #0 - file://src/data] route7                         INFO 
> direct:error
> [1) thread #0 - file://src/data] com                            ERROR
> Exchange[Id:ID-LONWD030282-2387-1312460018181-0-8, ExchangePattern:InOnly,
> Properties:{CamelToEndpoint=log://com?level=ERROR&showAll=true,
> CamelBatchComplete=false, CamelBatchSize=3, CamelCreatedTimestamp=Thu Aug 04
> 13:13:40 BST 2011,
> CamelFailureEndpoint=bean://radialTransformer?method=amendTrade%28%24%7Bbody%7D%2C+%24%7Bheader.previousVersion%7D%29,
> CamelFileExchangeFile=GenericFile[msg2_bond_amend_10856546.xml],
> CamelBatchIndex=1, CamelExceptionCaught=java.lang.IllegalArgumentException:
> Args can't be null},
> Headers:{previousVersion=com.nomura.fiet.stp.trademessage.BondTrade@a2d304,
> tradeEventType=AMEND}, BodyType:com.nomura.fiet.stp.trademessage.BondTrade,
> Body:com.nomura.fiet.stp.trademessage.BondTrade@14d659d,
> CaughtExceptionType:java.lang.IllegalArgumentException,
> CaughtExceptionMessage:Args can't be null,
> StackTrace:java.lang.IllegalArgumentException: Args can't be null
> 	at
> com.nomura.fiet.stp.radial.BondTradeRadialTransformer.amendTrade(BondTradeRadialTransformer.java:23)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 	at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:597)
> 
> 
> --
> View this message in context: http://camel.465427.n5.nabble.com/Problem-binding-multiple-params-to-a-bean-tp4666250p4666250.html
> Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Problem binding multiple params to a bean

Posted by "jason.parr" <ja...@usa.net>.
I was using release build 2.8 - ok so not supported in this version, ta.

--
View this message in context: http://camel.465427.n5.nabble.com/Problem-binding-multiple-params-to-a-bean-tp4666250p4666400.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Problem binding multiple params to a bean

Posted by Claus Ibsen <cl...@gmail.com>.
And you are using Camel 2.9 SNAPSHOT? As this is a new feature to be
able to use ${body}, ${header.foo} in the uri.

For older releases you can use the annotations to bind headers.
http://camel.apache.org/parameter-binding-annotations.html


On Thu, Aug 4, 2011 at 3:00 PM, jason.parr <ja...@usa.net> wrote:
>
> Hi,
>
> Try as I might I can't bind a value associated with a header onto a bean
> reference's second method argument. Null always gets passed to the second
> argument on amendTrade(p1,p2). I can log the header value OK, the correct
> method gets called but second argument is always null.
>
> I've tried most of the various ways that a bean can be bound to all with the
> same effect.
>
> Route:
>
>    from("direct:amend-bond-trade")
>      .log("direct:amend-bond-trade")
>      .to("log:showBody=false?showBodyType=true&showHeaders=true")
>      .log("Header>>>> ${header.previousVersion}")
>      .to("bean:radialTransformer?method=amendTrade(${body},
> ${header.previousVersion})")
>
> .to("activemq:queue:nomura.fiet.stp.radial.trades?jmsMessageType=Map");
>
> Log:
>
> [1) thread #0 - file://src/data] route5                         INFO
> direct:amend-bond-trade
> [1) thread #0 - file://src/data] showBody=false                 INFO
> Exchange[ExchangePattern:InOnly,
> Headers:{previousVersion=com.nomura.fiet.stp.trademessage.BondTrade@a2d304,
> tradeEventType=AMEND}, BodyType:com.nomura.fiet.stp.trademessage.BondTrade,
> Body:com.nomura.fiet.stp.trademessage.BondTrade@14d659d]
> [1) thread #0 - file://src/data] route5                         INFO
> Header>>>> com.nomura.fiet.stp.trademessage.BondTrade@a2d304
> [1) thread #0 - file://src/data] route7                         INFO
> direct:error
> [1) thread #0 - file://src/data] com                            ERROR
> Exchange[Id:ID-LONWD030282-2387-1312460018181-0-8, ExchangePattern:InOnly,
> Properties:{CamelToEndpoint=log://com?level=ERROR&showAll=true,
> CamelBatchComplete=false, CamelBatchSize=3, CamelCreatedTimestamp=Thu Aug 04
> 13:13:40 BST 2011,
> CamelFailureEndpoint=bean://radialTransformer?method=amendTrade%28%24%7Bbody%7D%2C+%24%7Bheader.previousVersion%7D%29,
> CamelFileExchangeFile=GenericFile[msg2_bond_amend_10856546.xml],
> CamelBatchIndex=1, CamelExceptionCaught=java.lang.IllegalArgumentException:
> Args can't be null},
> Headers:{previousVersion=com.nomura.fiet.stp.trademessage.BondTrade@a2d304,
> tradeEventType=AMEND}, BodyType:com.nomura.fiet.stp.trademessage.BondTrade,
> Body:com.nomura.fiet.stp.trademessage.BondTrade@14d659d,
> CaughtExceptionType:java.lang.IllegalArgumentException,
> CaughtExceptionMessage:Args can't be null,
> StackTrace:java.lang.IllegalArgumentException: Args can't be null
>        at
> com.nomura.fiet.stp.radial.BondTradeRadialTransformer.amendTrade(BondTradeRadialTransformer.java:23)
>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>        at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>        at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>        at java.lang.reflect.Method.invoke(Method.java:597)
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Problem-binding-multiple-params-to-a-bean-tp4666250p4666250.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/