You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by khong07 <he...@gmail.com> on 2013/02/20 01:03:26 UTC

marshal() with MarshalProcessor

Hi,
i have a route
    from("start").routeId("start").
	marshal().json(JsonLibrary.Jackson)
	.to("seda:next");

    producerTemplate.send(foo);

It's worked.

But i want send foo directly to seda:next, how i can do with
MarshalProcessor?
I tried:
    marshalProcessor = new
MarshalProcessor(camelContext.resolveDataFormat("json-jackson"));
    ...
    producerTemplate.asyncCallback("seda:next",
				new Processor() {
			
					@Override
					public void process(Exchange exchange) throws Exception {
						exchange.getIn().setBody(foo);
						marshalProcessor.process(exchange);
					}
				});

but it doesn't work?

Any idea?



--
View this message in context: http://camel.465427.n5.nabble.com/marshal-with-MarshalProcessor-tp5727842.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: marshal() with MarshalProcessor

Posted by Willem jiang <wi...@gmail.com>.
Did you have chance to call the start of MarshalProcessor?
I don't see any thing wrong from your route.


--  
Willem Jiang

Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
          http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem


Sent with Sparrow (http://www.sparrowmailapp.com/?sig)


On Thursday, February 21, 2013 at 2:20 AM, khong07 wrote:

> Hi,
>  
> I don't marshal in seda:next route because in seda:next route, i'll
> unmarshal.
>  
> from("seda:next").unmarshal().json(JsonLibrary.Jackson).to(...);  
>  
> So, i must marshal before sending to seda:next, that why i want using a
> ProducerTemplate.sendCallBack and call a MarshalProcessor inside Processor.
>  
>  
>  
>  
>  
> --
> View this message in context: http://camel.465427.n5.nabble.com/marshal-with-MarshalProcessor-tp5727842p5727895.html
> Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).
>  




Re: marshal() with MarshalProcessor

Posted by khong07 <he...@gmail.com>.
Hi,

@hekonsek: It's just about how to use correctly MarshalProcessor of Camel
instead of using marshal() in route builder. Not really a problem :) But
thank you for your help.

@Willem.Jiang
What does you mean "the start of MarshalProcessor"?


@all: thank you for your helps, I'll did an unit test and debug it to find
the root cause. If i found something, i'll update the thread. Regards,





--
View this message in context: http://camel.465427.n5.nabble.com/marshal-with-MarshalProcessor-tp5727842p5728050.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: marshal() with MarshalProcessor

Posted by Henryk Konsek <he...@gmail.com>.
Hi,

> So, i must marshal before sending to seda:next, that why i want using a
> ProducerTemplate.sendCallBack and call a MarshalProcessor inside Processor.

I'm felling a bit lost here. :) Would you explain us on higher level
of abstraction what exactly do you want to achieve? I could propose
some solution then.

Best regards.

-- 
Henryk Konsek
http://henryk-konsek.blogspot.com

Re: marshal() with MarshalProcessor

Posted by khong07 <he...@gmail.com>.
Hi,

I don't marshal in seda:next route because in seda:next route, i'll
unmarshal.

from("seda:next").unmarshal().json(JsonLibrary.Jackson).to(...); 

So, i must marshal before sending to seda:next, that why i want using a
ProducerTemplate.sendCallBack and call a MarshalProcessor inside Processor.





--
View this message in context: http://camel.465427.n5.nabble.com/marshal-with-MarshalProcessor-tp5727842p5727895.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: marshal() with MarshalProcessor

Posted by Henryk Konsek <he...@gmail.com>.
Hi,

> But i want send foo directly to seda:next, how i can do with
> MarshalProcessor?

Don't call MarshalProcessor from inline processor. Instead pass
MarshalProcessor to the DSL directly:

from("seda:next").process(marshalProcessor).to(...);

Best regards.

--
Henryk Konsek
http://henryk-konsek.blogspot.com

Re: marshal() with MarshalProcessor

Posted by khong07 <he...@gmail.com>.
Hi,

I'm usingdirectly  MarshalProcessor of camel
(org.apache.camel.processor.MarshalProcessor).
And in it, the marshal method in the DataFormat is called as well.



--
View this message in context: http://camel.465427.n5.nabble.com/marshal-with-MarshalProcessor-tp5727842p5727852.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: marshal() with MarshalProcessor

Posted by Willem jiang <wi...@gmail.com>.
What's your MarshalProcessor looks like ?
Did you call the marshal method in the DataFormat?


--  
Willem Jiang

Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
          http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem





On Wednesday, February 20, 2013 at 8:03 AM, khong07 wrote:

> Hi,
> i have a route
> from("start").routeId("start").
> marshal().json(JsonLibrary.Jackson)
> .to("seda:next");
>  
> producerTemplate.send(foo);
>  
> It's worked.
>  
> But i want send foo directly to seda:next, how i can do with
> MarshalProcessor?
> I tried:
> marshalProcessor = new
> MarshalProcessor(camelContext.resolveDataFormat("json-jackson"));
> ...
> producerTemplate.asyncCallback("seda:next",
> new Processor() {
>  
> @Override
> public void process(Exchange exchange) throws Exception {
> exchange.getIn().setBody(foo);
> marshalProcessor.process(exchange);
> }
> });
>  
> but it doesn't work?
>  
> Any idea?
>  
>  
>  
> --
> View this message in context: http://camel.465427.n5.nabble.com/marshal-with-MarshalProcessor-tp5727842.html
> Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).