You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by ghosh <bu...@gmail.com> on 2011/02/24 11:37:03 UTC

Camel custom component

Hi 

I have a requirement where I need to persist xml in a jcr compliant repo and
subsequently read it
back in camel route. For that I have created a custom component where
producer impl persists the data
and comsumer reads it back. But the problem I facing is....my routes are
going to be like below

route-1
from("bean://task1")
to("myjcr://path=node1/node2/..") ------> here I am persisting xml

route-2
from("bean://task2")
to(''myjcr://path=node1/node2/..") --------> here I need to retrive the xml

but as we know the consumer will never be invoked if it is used in a "to"
endpoint,
I am thinking of changing my custom component such a way that the producer
would handle 
both persisting and retrieval (will pass action=persist/retrieve in uri) or
go for two different compnent. I am not sure how do we deal with such
situation in camel. 

Ghosh
-- 
View this message in context: http://camel.465427.n5.nabble.com/Camel-custom-component-tp3398359p3398359.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel custom component

Posted by Claus Straube <cl...@catify.com>.
Hi Gosh,

producer is always to()...
consumer is always from()...

Regardless, if data goes in or out. The point is, that you have to force 
the producer to do something while a consumer does it itself (e.g. by 
polling, on event, etc.)

Best regards - Claus

On 24.02.2011 11:37, ghosh wrote:
> Hi
>
> I have a requirement where I need to persist xml in a jcr compliant repo and
> subsequently read it
> back in camel route. For that I have created a custom component where
> producer impl persists the data
> and comsumer reads it back. But the problem I facing is....my routes are
> going to be like below
>
> route-1
> from("bean://task1")
> to("myjcr://path=node1/node2/..") ------>  here I am persisting xml
>
> route-2
> from("bean://task2")
> to(''myjcr://path=node1/node2/..") -------->  here I need to retrive the xml
>
> but as we know the consumer will never be invoked if it is used in a "to"
> endpoint,
> I am thinking of changing my custom component such a way that the producer
> would handle
> both persisting and retrieval (will pass action=persist/retrieve in uri) or
> go for two different compnent. I am not sure how do we deal with such
> situation in camel.
>
> Ghosh


Re: Camel custom component

Posted by Claus Ibsen <cl...@gmail.com>.
Check out the Content Enricher EIP
http://camel.apache.org/content-enricher.html

And it's not advised to start a route from(bean) as it would mean
Camel will poll the bean continuously. Instead from the bean send a
message to a Camel route, or directly to the JCR

For that use ProducerTemplate, or the @Produce annotation.

Google the Camel website for details.


On Fri, Feb 25, 2011 at 8:24 AM, ghosh <bu...@gmail.com> wrote:
>
> Thanks Claus for your precise but meaningful reply...
>
> but my question is .. am I trying to do something which is against the camel
> philosophy or
> that is quite normal in such kind of scenario ?
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-custom-component-tp3398359p3399699.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
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: Camel custom component

Posted by ghosh <bu...@gmail.com>.
Thanks Claus for your precise but meaningful reply...

but my question is .. am I trying to do something which is against the camel
philosophy or 
that is quite normal in such kind of scenario ? 
-- 
View this message in context: http://camel.465427.n5.nabble.com/Camel-custom-component-tp3398359p3399699.html
Sent from the Camel - Users mailing list archive at Nabble.com.