camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cmoulliard <cmoulli...@gmail.com>
Subject RE: How can I set the content of the body when I left a bean and before to go to the next bean ?
Date Mon, 07 Jul 2008 08:42:09 GMT

Hi Claus,

Unfortunately, what you propose does not work. For your information, my
activemq is defined in my camelcontext as a vm queue.

When I use in my route "direct" endpoint instead of "activemq", the object
transformed is well send to the "save" bean.

From("File:///c:/temp")
.unmarshall(jaxb)
.to("direct:input");
 
2nd part :
>From ("direct.input")
.to("bean:converter)
.to("bean:save");
.to("direct:output");

Regards,

Charles 


Claus Ibsen wrote:
> 
> Hi
> 
> I assume since the original input is from a file you are doing an InOnly
> message exchange pattern (MEP). 
> 
> So whenever you receive a message from the jms queue:myqueue and it hasn't
> a reply-to set it should also be a InOnly message out-of-the-box.
> 
> So I would expect that if you set the altered message on the In message
> then the save bean should see this change:
> 
>     private void sendTransformedMesage(Exchange in, Object object) {
>         in.getIn().setBody(object);
>     }
> 
> 
> Med venlig hilsen
>  
> Claus Ibsen
> ......................................
> Silverbullet
> Skovsgårdsvænget 21
> 8362 Hørning
> Tlf. +45 2962 7576
> Web: www.silverbullet.dk
> 
> -----Original Message-----
> From: cmoulliard [mailto:cmoulliard@gmail.com] 
> Sent: 7. juli 2008 08:40
> To: camel-user@activemq.apache.org
> Subject: RE: How can I set the content of the body when I left a bean and
> before to go to the next bean ?
> 
> 
> Hi claus,
> 
> My explanation was not enough clear. The JAXB unmarshalling has already be
> done :
> Here is my routing for the first part of the job:
> 
> DataFormat jaxb = new JaxbDataFormat("com.myapplication.schema.myschema");
> 
> From("File:///c:/temp").
> unmarshall(jaxb)
> .to("activemq:queue:myqueue");
> 
> 2nd part :
> From ("activemq:queue:myqueue")
> .to("bean:converter)
> .to("bean:save");
> 
> My "converter" bean receives as input the JAXB object (through the message
> body coming from the queue) and has to perform a java to java
> transformation. In this bean, I perform the transformation and I would
> like
> to send the transformation result to the "save" bean endpoint.
> 
> I try to send a new message using the following code (after analizing the
> pipeline camel test case) but without success :
> 
> public Class Converter implements Processor (
>     
>     public void process(Exchange in) throws Exception (
>     .... part where transformation of the jaxb object into another java
> object took place
>     sendTransformedMessage(in, object);
>     }
> 
> 
>     private void sendTransformedMesage(Exchange in, Object object) {
>         in.getOut(true).copyFrom(Exchange.getIn());
>         in.getOut()/setBody(object);
>     }
> 
> Should I have to define the pattern as a InOut between "converter" and
> "save" ?
> 
> Regards,
> 
> Charles
> 
> 
> Claus Ibsen wrote:
>> 
>> Hi Charles
>> 
>> Convertion from the dataformat JAXB to Order is supported out of the box
>> in Camel with its Data Format:
>> http://activemq.apache.org/camel/data-format.html
>> 
>> And the JAXB:
>> http://activemq.apache.org/camel/jaxb.html
>> 
>> 
>> DataFormat jaxb = new JaxbDataFormat("com.mycompany");
>> // where com.mycompany is the package where your domain objecs it - eg
>> Order
>> 
>> from("File:///c:/temp").
>> unmarshal(jaxb).
>> to("bean:save);
>> 
>> Then your Order class must be annotated with the JAXB annotations for
>> this.
>> And you should have a jaxb.index file the JAXB classes you have in the
>> package = Order.
>> 
>> For examples see the camel-jaxb component that has a unit DataFormatTest
>> that does something like the above.
>> 
>> See this unit test and its related files and you will have something to
>> go
>> along with.
>> 
>> 
>> Med venlig hilsen
>>  
>> Claus Ibsen
>> ......................................
>> Silverbullet
>> Skovsgårdsvænget 21
>> 8362 Hørning
>> Tlf. +45 2962 7576
>> Web: www.silverbullet.dk
>> -----Original Message-----
>> From: cmoulliard [mailto:cmoulliard@gmail.com] 
>> Sent: 4. juli 2008 18:05
>> To: camel-user@activemq.apache.org
>> Subject: How can I set the content of the body when I left a bean and
>> before to go to the next bean ?
>> 
>> 
>> Hi,
>> 
>> In a bean component receiving a message, I would like to transform the
>> content of a object received from something into something different
>> (like
>> from JAXB towards Order object).
>> To achieve this, I create a pipeline routes :
>> 
>> from("File:///c:/temp").
>> to("bean:converter).
>> to("bean:save");
>> 
>> Unfortunately, when I define :  
>> 
>> in.getOut().setBody(order, Order.class) 
>> 
>> after the transformation step in order to send the message to my bean :
>> save, I see that the message is send back to my bean converter and not
>> propagated to the bean : save !!!!
>> 
>> Where is the issue ? How Can I put the order object into the message that
>> Camel will send to bean : save
>> 
>> Regards,
>> 
>> Charles
>> -- 
>> View this message in context:
>> http://www.nabble.com/How-can-I-set-the-content-of-the-body-when-I-left-a-bean-and-before-to-go-to-the-next-bean---tp18282228s22882p18282228.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>> 
>> 
>> 
> 
> -- 
> View this message in context:
> http://www.nabble.com/How-can-I-set-the-content-of-the-body-when-I-left-a-bean-and-before-to-go-to-the-next-bean---tp18282228s22882p18310870.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-can-I-set-the-content-of-the-body-when-I-left-a-bean-and-before-to-go-to-the-next-bean---tp18282228s22882p18312377.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Mime
View raw message