On Mon, Jul 11, 2011 at 3:05 PM, dunnlow <dunn...@yahoo.com> wrote:
> Claus,
> Thanks for the reply (your book has been a HUGE help btw).
>
> Sorry, I am still missing something.  I understand your comment about the
> stream component, which clears up one question.  However, I tried passing
> the message to a bean, as:
>
> ("activemq:queue:myholdingqueue?testConnectionOnStartup=true").converBodyTo(String.class).beanRef("myCamelBean").to("stream:out");
>
> my bean is defined via Spring XML:
> <bean id="myCamelBean" class="com.mycc.beans.MyCamelBean"/>
>
> and the actual class just has one method:
>
> public String toSql(Object obj){
>   System.out.println("class is "+obj.getClass().getName());
>   if (obj.getClass().getName().equals("java.lang.String")){
>      String sre = (String) obj;
>      String.out.println("string is ["+str+"]");
>   }
> }
>
> What I end up seeing on system.out is
> "class is java.lang.String"
> "string is [Hello this is the text in my TextMessage]"
>
> My question:
>
> 1) If I leave the "ConvertBodyTo()" out of the route, the bean never seems
> to be called. Why is that?
>

You use Object as the type of the method. That is too broad in the sense.


> 2) I was expecting that my bean would get some sort of message object from
> which I could call a getProperty, but it only gets a string with the header
> (with the ConvertBodyTo).  Is there something else I should be using to get
> the message to my Bean?
>

You can use one of the Camel APIs to get the Camel Message such as

 public String toSql(Exchange exchange){

Then you can access the headers and body as follows


String body = exchange.getIn().getBody(String.class);
Map<String, Object> headers = exchange.getIn().getHeaders();


You may want to read chapter 3 and 4 to see how you can use beans /
processors etc with Camel.


> Thanks again.
>
>
>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/How-to-use-JMS-TextMessage-Properties-tp4574811p4574918.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



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

Reply via email to