You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by flovansi <fl...@swift.com> on 2013/11/20 17:29:04 UTC
Consume from a java bean
Hi all,
Is it possible to consume message from a Java bean?
Something like:
<from ref="myBean"/>
where myBean could be a custom bean to get JMS message from a queue, or
anything you can think of.
I know that I can achieve that by creating custom Camel Component but a Java
Bean could be simpler in my case.
If it's not possible, is there any other way to achieve that?
Thank you,
Florent
--
View this message in context: http://camel.465427.n5.nabble.com/Consume-from-a-java-bean-tp5743580.html
Sent from the Camel Development mailing list archive at Nabble.com.
Re: Consume from a java bean
Posted by Claus Ibsen <cl...@gmail.com>.
Use bean:myBean to tell Camel its a bean. And you can also specify the method
"bean:myBean?method=myMethod"
On Thu, Nov 21, 2013 at 10:00 AM, flovansi
<fl...@swift.com> wrote:
> I tried <from ref="myBean"/> and I got the exception:
>
> Caused by: org.apache.camel.NoSuchEndpointException: No endpoint could be found for: ref:consumerBean, please check your camel registry with id consumerBean
>
> By looking into the code, I figured out that the bean must be an Endpoint (which was not my case).
>
> So I guess it's easier and cleaner to create a custom Camel Component.
>
> Thank you for your answers Claus.
> From: Claus Ibsen-2 [via Camel] [mailto:ml-node+s465427n5743588h5@n5.nabble.com]
> Sent: mercredi 20 novembre 2013 21:16
> To: VANSILIETTE Florent
> Subject: Re: Consume from a java bean
>
> Ah okay, yeah you can do from(bean) but then Camel will just keep
> calling the method on the bean in endless loop, using a single
> threaded consumer.
> So if there is no messages on the JMS queue to process you would need
> to sleep the thread or something as there is no message for Camel to
> route.
>
> You can also just have a from direct and then from whatever bean you
> have send a message to that direct endpoint for Camel route.
>
>
> On Wed, Nov 20, 2013 at 9:00 PM, flovansi <[hidden email]</user/SendEmail.jtp?type=node&node=5743588&i=0>> wrote:
>
>>
>>
>>
>>
>>
>> I m not sure it'll be possible with the @Consume annotation.
>>
>>
>> I want to be able to create an exchange in the POJO and to manage manually the JMS transaction when consuming message.
>> If I've well understood, the @Consume annotation cannot fit in this case as we have to specify an endpoint to consume from.
>>
>>
>> Thank you for your answer anyway and please correct me if I'm wrong.
>>
>>
>> Florent
>>
>> On 20 nov. 2013, at 17:33, "Claus Ibsen-2 [via Camel]" < ml-node+[hidden email]</user/SendEmail.jtp?type=node&node=5743588&i=1> > wrote:
>>
>>
>>
>> Hi
>>
>> Yeah see
>> http://camel.apache.org/pojo-messaging-example.html
>>
>> You dont need a route if you use a pojo with the @Consume annotation
>> as shown in that example.
>>
>>
>> On Wed, Nov 20, 2013 at 5:29 PM, flovansi < [hidden email] > wrote:
>>
>> > Hi all,
>> >
>> > Is it possible to consume message from a Java bean?
>> >
>> > Something like:
>> >
>> > <from ref="myBean"/>
>> >
>> > where myBean could be a custom bean to get JMS message from a queue, or
>> > anything you can think of.
>> >
>> > I know that I can achieve that by creating custom Camel Component but a Java
>> > Bean could be simpler in my case.
>> >
>> > If it's not possible, is there any other way to achieve that?
>> >
>> > Thank you,
>> >
>> > Florent
>> >
>> >
>> >
>> > --
>> > View this message in context:
>> http://camel.465427.n5.nabble.com/Consume-from-a-java-bean-tp5743580.html
>> > Sent from the Camel Development mailing list archive at
>> Nabble.com .
>>
>>
>>
>> --
>> Claus Ibsen
>> -----------------
>> Red Hat, Inc.
>> Email:
>> [hidden email]
>> Twitter: davsclaus
>> Blog:
>> http://davsclaus.com
>> Author of Camel in Action:
>> http://www.manning.com/ibsen
>>
>>
>>
>>
>> If you reply to this email, your message will be added to the discussion below:
>> http://camel.465427.n5.nabble.com/Consume-from-a-java-bean-tp5743580p5743581.html
>>
>>
>> To unsubscribe from Consume from a java bean,
>> click here .
>> NAML
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> --
>> View this message in context: http://camel.465427.n5.nabble.com/Consume-from-a-java-bean-tp5743580p5743587.html
>> Sent from the Camel Development mailing list archive at Nabble.com.
>
>
>
> --
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> Email: [hidden email]</user/SendEmail.jtp?type=node&node=5743588&i=2>
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
>
> ________________________________
> If you reply to this email, your message will be added to the discussion below:
> http://camel.465427.n5.nabble.com/Consume-from-a-java-bean-tp5743580p5743588.html
> To unsubscribe from Consume from a java bean, click here<http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5743580&code=ZmxvcmVudC52YW5zaWxpZXR0ZUBzd2lmdC5jb218NTc0MzU4MHwtMjA1MTYxNjE4MA==>.
> NAML<http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Consume-from-a-java-bean-tp5743580p5743602.html
> Sent from the Camel Development mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
RE: Consume from a java bean
Posted by flovansi <fl...@swift.com>.
I tried <from ref="myBean"/> and I got the exception:
Caused by: org.apache.camel.NoSuchEndpointException: No endpoint could be found for: ref:consumerBean, please check your camel registry with id consumerBean
By looking into the code, I figured out that the bean must be an Endpoint (which was not my case).
So I guess it's easier and cleaner to create a custom Camel Component.
Thank you for your answers Claus.
From: Claus Ibsen-2 [via Camel] [mailto:ml-node+s465427n5743588h5@n5.nabble.com]
Sent: mercredi 20 novembre 2013 21:16
To: VANSILIETTE Florent
Subject: Re: Consume from a java bean
Ah okay, yeah you can do from(bean) but then Camel will just keep
calling the method on the bean in endless loop, using a single
threaded consumer.
So if there is no messages on the JMS queue to process you would need
to sleep the thread or something as there is no message for Camel to
route.
You can also just have a from direct and then from whatever bean you
have send a message to that direct endpoint for Camel route.
On Wed, Nov 20, 2013 at 9:00 PM, flovansi <[hidden email]</user/SendEmail.jtp?type=node&node=5743588&i=0>> wrote:
>
>
>
>
>
> I m not sure it'll be possible with the @Consume annotation.
>
>
> I want to be able to create an exchange in the POJO and to manage manually the JMS transaction when consuming message.
> If I've well understood, the @Consume annotation cannot fit in this case as we have to specify an endpoint to consume from.
>
>
> Thank you for your answer anyway and please correct me if I'm wrong.
>
>
> Florent
>
> On 20 nov. 2013, at 17:33, "Claus Ibsen-2 [via Camel]" < ml-node+[hidden email]</user/SendEmail.jtp?type=node&node=5743588&i=1> > wrote:
>
>
>
> Hi
>
> Yeah see
> http://camel.apache.org/pojo-messaging-example.html
>
> You dont need a route if you use a pojo with the @Consume annotation
> as shown in that example.
>
>
> On Wed, Nov 20, 2013 at 5:29 PM, flovansi < [hidden email] > wrote:
>
> > Hi all,
> >
> > Is it possible to consume message from a Java bean?
> >
> > Something like:
> >
> > <from ref="myBean"/>
> >
> > where myBean could be a custom bean to get JMS message from a queue, or
> > anything you can think of.
> >
> > I know that I can achieve that by creating custom Camel Component but a Java
> > Bean could be simpler in my case.
> >
> > If it's not possible, is there any other way to achieve that?
> >
> > Thank you,
> >
> > Florent
> >
> >
> >
> > --
> > View this message in context:
> http://camel.465427.n5.nabble.com/Consume-from-a-java-bean-tp5743580.html
> > Sent from the Camel Development mailing list archive at
> Nabble.com .
>
>
>
> --
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> Email:
> [hidden email]
> Twitter: davsclaus
> Blog:
> http://davsclaus.com
> Author of Camel in Action:
> http://www.manning.com/ibsen
>
>
>
>
> If you reply to this email, your message will be added to the discussion below:
> http://camel.465427.n5.nabble.com/Consume-from-a-java-bean-tp5743580p5743581.html
>
>
> To unsubscribe from Consume from a java bean,
> click here .
> NAML
>
>
>
>
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Consume-from-a-java-bean-tp5743580p5743587.html
> Sent from the Camel Development mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
Red Hat, Inc.
Email: [hidden email]</user/SendEmail.jtp?type=node&node=5743588&i=2>
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
________________________________
If you reply to this email, your message will be added to the discussion below:
http://camel.465427.n5.nabble.com/Consume-from-a-java-bean-tp5743580p5743588.html
To unsubscribe from Consume from a java bean, click here<http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5743580&code=ZmxvcmVudC52YW5zaWxpZXR0ZUBzd2lmdC5jb218NTc0MzU4MHwtMjA1MTYxNjE4MA==>.
NAML<http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
--
View this message in context: http://camel.465427.n5.nabble.com/Consume-from-a-java-bean-tp5743580p5743602.html
Sent from the Camel Development mailing list archive at Nabble.com.
Re: Consume from a java bean
Posted by Claus Ibsen <cl...@gmail.com>.
Ah okay, yeah you can do from(bean) but then Camel will just keep
calling the method on the bean in endless loop, using a single
threaded consumer.
So if there is no messages on the JMS queue to process you would need
to sleep the thread or something as there is no message for Camel to
route.
You can also just have a from direct and then from whatever bean you
have send a message to that direct endpoint for Camel route.
On Wed, Nov 20, 2013 at 9:00 PM, flovansi <fl...@swift.com> wrote:
>
>
>
>
>
> I m not sure it'll be possible with the @Consume annotation.
>
>
> I want to be able to create an exchange in the POJO and to manage manually the JMS transaction when consuming message.
> If I've well understood, the @Consume annotation cannot fit in this case as we have to specify an endpoint to consume from.
>
>
> Thank you for your answer anyway and please correct me if I'm wrong.
>
>
> Florent
>
> On 20 nov. 2013, at 17:33, "Claus Ibsen-2 [via Camel]" < ml-node+s465427n5743581h88@n5.nabble.com > wrote:
>
>
>
> Hi
>
> Yeah see
> http://camel.apache.org/pojo-messaging-example.html
>
> You dont need a route if you use a pojo with the @Consume annotation
> as shown in that example.
>
>
> On Wed, Nov 20, 2013 at 5:29 PM, flovansi < [hidden email] > wrote:
>
> > Hi all,
> >
> > Is it possible to consume message from a Java bean?
> >
> > Something like:
> >
> > <from ref="myBean"/>
> >
> > where myBean could be a custom bean to get JMS message from a queue, or
> > anything you can think of.
> >
> > I know that I can achieve that by creating custom Camel Component but a Java
> > Bean could be simpler in my case.
> >
> > If it's not possible, is there any other way to achieve that?
> >
> > Thank you,
> >
> > Florent
> >
> >
> >
> > --
> > View this message in context:
> http://camel.465427.n5.nabble.com/Consume-from-a-java-bean-tp5743580.html
> > Sent from the Camel Development mailing list archive at
> Nabble.com .
>
>
>
> --
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> Email:
> [hidden email]
> Twitter: davsclaus
> Blog:
> http://davsclaus.com
> Author of Camel in Action:
> http://www.manning.com/ibsen
>
>
>
>
> If you reply to this email, your message will be added to the discussion below:
> http://camel.465427.n5.nabble.com/Consume-from-a-java-bean-tp5743580p5743581.html
>
>
> To unsubscribe from Consume from a java bean,
> click here .
> NAML
>
>
>
>
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Consume-from-a-java-bean-tp5743580p5743587.html
> Sent from the Camel Development mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
Re: Consume from a java bean
Posted by flovansi <fl...@swift.com>.
I m not sure it'll be possible with the @Consume annotation.
I want to be able to create an exchange in the POJO and to manage manually the JMS transaction when consuming message.
If I've well understood, the @Consume annotation cannot fit in this case as we have to specify an endpoint to consume from.
Thank you for your answer anyway and please correct me if I'm wrong.
Florent
On 20 nov. 2013, at 17:33, "Claus Ibsen-2 [via Camel]" < ml-node+s465427n5743581h88@n5.nabble.com > wrote:
Hi
Yeah see
http://camel.apache.org/pojo-messaging-example.html
You dont need a route if you use a pojo with the @Consume annotation
as shown in that example.
On Wed, Nov 20, 2013 at 5:29 PM, flovansi < [hidden email] > wrote:
> Hi all,
>
> Is it possible to consume message from a Java bean?
>
> Something like:
>
> <from ref="myBean"/>
>
> where myBean could be a custom bean to get JMS message from a queue, or
> anything you can think of.
>
> I know that I can achieve that by creating custom Camel Component but a Java
> Bean could be simpler in my case.
>
> If it's not possible, is there any other way to achieve that?
>
> Thank you,
>
> Florent
>
>
>
> --
> View this message in context:
http://camel.465427.n5.nabble.com/Consume-from-a-java-bean-tp5743580.html
> Sent from the Camel Development mailing list archive at
Nabble.com .
--
Claus Ibsen
-----------------
Red Hat, Inc.
Email:
[hidden email]
Twitter: davsclaus
Blog:
http://davsclaus.com
Author of Camel in Action:
http://www.manning.com/ibsen
If you reply to this email, your message will be added to the discussion below:
http://camel.465427.n5.nabble.com/Consume-from-a-java-bean-tp5743580p5743581.html
To unsubscribe from Consume from a java bean,
click here .
NAML
--
View this message in context: http://camel.465427.n5.nabble.com/Consume-from-a-java-bean-tp5743580p5743587.html
Sent from the Camel Development mailing list archive at Nabble.com.
Re: Consume from a java bean
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
Yeah see
http://camel.apache.org/pojo-messaging-example.html
You dont need a route if you use a pojo with the @Consume annotation
as shown in that example.
On Wed, Nov 20, 2013 at 5:29 PM, flovansi <fl...@swift.com> wrote:
> Hi all,
>
> Is it possible to consume message from a Java bean?
>
> Something like:
>
> <from ref="myBean"/>
>
> where myBean could be a custom bean to get JMS message from a queue, or
> anything you can think of.
>
> I know that I can achieve that by creating custom Camel Component but a Java
> Bean could be simpler in my case.
>
> If it's not possible, is there any other way to achieve that?
>
> Thank you,
>
> Florent
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Consume-from-a-java-bean-tp5743580.html
> Sent from the Camel Development mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen