You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by kalber <Ka...@swslt.com> on 2015/06/13 14:35:18 UTC

Pojo @Consumer Annotation

I'm using this in a pojo :

@Consume(uri = "sql: select codaz, codbus, logmsg from bus.buslogger where
loglev = 'STS_CFG' and (logmsg like 'V60%' or logmsg like 'V65%') and
instr(logmsg,'UNREACHABLE') = 0 and instr(logmsg,'UNKNOWN') = 0 and
substring(scriptver,instr(scriptver,'=')+1) >= '2.2.0' and codaz != 0 and
codbus = 6037 order by daterecv asc , hourrecv asc
?dataSource=#dataSource.nagios&consumer.useIterator=false&consumer.routeEmptyResultSet=true&outputClass=it.sad.batch.eam.transfer.obliRelease.ObliReleaseResult&consumer.bridgeErrorHandler=true")
public void process(Object body) {
     System.out.println("hello");
}
But body object in process method is null.
Do i something wrong or misunderstood the use of @Consumer ?

thanks
Karlheinz



-----
kh
--
View this message in context: http://camel.465427.n5.nabble.com/Pojo-Consumer-Annotation-tp5768168.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Pojo @Consumer Annotation

Posted by Claus Ibsen <cl...@gmail.com>.
Ah its the timer that sends an empty body. The timer always sends a null body.

The @Consume is for POJO routing where you do not need to write a Camel route.
So for example remove the route with the timer.

Though to bootstrap the @Consumer it depends a bit how you run Camel.
To have the @Consume being detected by Camel that creates the consumer
and calls the bean.

See this example
http://camel.apache.org/pojo-messaging-example.html

On Wed, Jun 17, 2015 at 8:21 AM, kalber <Ka...@swslt.com> wrote:
> Done,
>
> in.body is still null.
>
> Route :
> ---------
> from("timer://?repeatCount=1").bean(MyService.class)
>
> Bean
> --------
> public class MyService {
>
>  @Consume(uri = "sql: select codaz, codbus, logmsg from bus.buslogger where
> loglev = 'STS_CFG'?dataSource=#dataSource.nagios")
>     public void process(Exchange exchange) {
>         System.out.println("wait");
>     }
> }
>
> I attached a screenshot, so you can see debug.
>
>
>
>
> -----
> kh
> --
> View this message in context: http://camel.465427.n5.nabble.com/Pojo-Consumer-Annotation-tp5768168p5768320.html
> Sent from the Camel - Users 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
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Re: Pojo @Consumer Annotation

Posted by kalber <Ka...@swslt.com>.
Done,

in.body is still null.

Route :
---------
from("timer://?repeatCount=1").bean(MyService.class)

Bean
--------
public class MyService {

 @Consume(uri = "sql: select codaz, codbus, logmsg from bus.buslogger where
loglev = 'STS_CFG'?dataSource=#dataSource.nagios")
    public void process(Exchange exchange) {
        System.out.println("wait");
    }
}

I attached a screenshot, so you can see debug.




-----
kh
--
View this message in context: http://camel.465427.n5.nabble.com/Pojo-Consumer-Annotation-tp5768168p5768320.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Pojo @Consumer Annotation

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Okay what if you change the parameter to be Exchange. And then set a
break point, what do you see?



On Tue, Jun 16, 2015 at 10:52 AM, kalber <Ka...@swslt.com> wrote:
> Hi,
>
> I use just the last version 2.15.2.
>
>
>
>
>
> -----
> kh
> --
> View this message in context: http://camel.465427.n5.nabble.com/Pojo-Consumer-Annotation-tp5768168p5768302.html
> Sent from the Camel - Users 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
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Re: Pojo @Consumer Annotation

Posted by kalber <Ka...@swslt.com>.
Hi,

I use just the last version 2.15.2.





-----
kh
--
View this message in context: http://camel.465427.n5.nabble.com/Pojo-Consumer-Annotation-tp5768168p5768302.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Pojo @Consumer Annotation

Posted by kalber <Ka...@swslt.com>.
15-06-2015 13:31:24 INFO  [main] MainSupport: Apache Camel 2.15.2 starting



-----
kh
--
View this message in context: http://camel.465427.n5.nabble.com/Pojo-Consumer-Annotation-tp5768168p5768259.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Pojo @Consumer Annotation

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

What version of Camel do you use? And have you tried with latest release?

On Mon, Jun 15, 2015 at 11:37 AM, kalber <Ka...@swslt.com> wrote:
> Hi,
>
> i simplify my select to guarantee a result and remove all sql options :
>
> @Consume(uri = "sql: select codaz, codbus, logmsg from bus.buslogger where
> loglev = 'STS_CFG'?dataSource=#dataSource.nagios")
>     public void process(Object body) {
>         System.out.println("wait");
>     }
>
> but parameter body in process method is still null.
>
>
>
>
>
> -----
> kh
> --
> View this message in context: http://camel.465427.n5.nabble.com/Pojo-Consumer-Annotation-tp5768168p5768249.html
> Sent from the Camel - Users 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
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Re: Pojo @Consumer Annotation

Posted by kalber <Ka...@swslt.com>.
Hi,

i simplify my select to guarantee a result and remove all sql options :

@Consume(uri = "sql: select codaz, codbus, logmsg from bus.buslogger where
loglev = 'STS_CFG'?dataSource=#dataSource.nagios")
    public void process(Object body) {
        System.out.println("wait");
    }

but parameter body in process method is still null.





-----
kh
--
View this message in context: http://camel.465427.n5.nabble.com/Pojo-Consumer-Annotation-tp5768168p5768249.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Pojo @Consumer Annotation

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Does the SQL return any data at all?

You have set consumer.routeEmptyResultSet which could be that an empty
body is sent

On Sat, Jun 13, 2015 at 2:35 PM, kalber <Ka...@swslt.com> wrote:
> I'm using this in a pojo :
>
> @Consume(uri = "sql: select codaz, codbus, logmsg from bus.buslogger where
> loglev = 'STS_CFG' and (logmsg like 'V60%' or logmsg like 'V65%') and
> instr(logmsg,'UNREACHABLE') = 0 and instr(logmsg,'UNKNOWN') = 0 and
> substring(scriptver,instr(scriptver,'=')+1) >= '2.2.0' and codaz != 0 and
> codbus = 6037 order by daterecv asc , hourrecv asc
> ?dataSource=#dataSource.nagios&consumer.useIterator=false&consumer.routeEmptyResultSet=true&outputClass=it.sad.batch.eam.transfer.obliRelease.ObliReleaseResult&consumer.bridgeErrorHandler=true")
> public void process(Object body) {
>      System.out.println("hello");
> }
> But body object in process method is null.
> Do i something wrong or misunderstood the use of @Consumer ?
>
> thanks
> Karlheinz
>
>
>
> -----
> kh
> --
> View this message in context: http://camel.465427.n5.nabble.com/Pojo-Consumer-Annotation-tp5768168.html
> Sent from the Camel - Users 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
hawtio: http://hawt.io/
fabric8: http://fabric8.io/