It works now except that I have the following error (btw, the objects
posted in the JMS queue are serializable) .
CaughtExceptionType:java.io.NotSerializableException,
CaughtExceptionMessage:org.apache.camel.component.jms.JmsQueueEndpoint,
StackTrace:java.io.NotSerializableException:
org.apache.camel.component.jms.JmsQueueEndpoint
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081)
at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1251)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1075)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:302)
at
org.apache.camel.component.bean.BeanInvocation.writeExternal(BeanInvocation.java:104)
at
java.io.ObjectOutputStream.writeExternalData(ObjectOutputStream.java:1310)
at
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1288)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1079)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:302)
at
org.apache.activemq.command.ActiveMQObjectMessage.storeContent(ActiveMQObjectMessage.java:98)
Why do we have to inject two times the reference of the uri, this is
not so very logic ?
@EndpointInject(name = "queueReportingEndpoint")
private ConsumerTemplate consumer;
@EndpointInject(name = "queueReportingEndpoint")
private Endpoint endpoint;
Regards,
Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer
*****************************
blog : http://cmoulliard.blogspot.com
On Mon, Sep 21, 2009 at 3:14 PM, Claus Ibsen <[email protected]> wrote:
> Charles you do post your problems to soon.
>
> The NPE is of course because ConsumerTemplate is never initialized.
>
> Just add @EndpointInject to it as well
>
> @EndpointInject
> private ConsumerTemplate consumer;
>
>
>
> On Mon, Sep 21, 2009 at 3:06 PM, Charles Moulliard <[email protected]>
> wrote:
>> There is something strange. I receive a NPE exception at the line
>> where I create an exchange from consumer :
>>
>> �...@endpointinject(name = "queueReportingEndpoint")
>> private Endpoint endpoint;
>>
>> private ConsumerTemplate consumer;
>>
>> public List<Map<String, Object>> collectMessages() {
>>
>> Log.info("Endpoint : " + endpoint.getEndpointUri());
>>
>> Exchange exch = consumer.receive(endpoint);
>>
>> If I call directly consumer.receiveBody(endpoint, List.class); I have
>> the same error. I tough that the problem come from the endpoint
>> injection, but I have also a NPE if I use the uri of the endpoint in
>> the receiveBody method
>>
>> Here is the trace :
>>
>> Time=Mon Sep 21 15:00:00 CEST 2009, calendar=null,
>> previousFireTime=Mon Sep 21 14:58:00 CEST 2009,
>> CamelBeanMethodName=null}, BodyType:org.quartz.JobDetail,
>> Body:JobDetail
>> 'DEFAULT.quartz://x3sReporting/clientError?cron=0+0%2F2+9-18+%3F+*+MON-FRI':
>> jobClass: 'org.apache.camel.component.quartz.CamelJob isStateful:
>> false isVolatile: false isDurable: false requestsRecovers: false
>> 15:00:00,000 | INFO | heduler_Worker-2 | x3s
>> | rg.apache.camel.processor.Logger 88 | Exchange[
>> , BodyType:org.quartz.JobDetail
>> , Body:JobDetail
>> 'DEFAULT.quartz://x3sReporting/clientError?cron=0+0%2F2+9-18+%3F+*+MON-FRI':
>> jobClass: 'org.apache.camel.component.quartz.CamelJob isStateful:
>> false isVolatile: false isDurable: false requestsRecovers: false
>> , CaughtExceptionType:java.lang.NullPointerException,
>> CaughtExceptionMessage:null, StackTrace:java.lang.NullPointerException
>> at
>> com.xpectis.x3s.core.util.ReportingConsumer.collectMessages(ReportingConsumer.java:27)
>>
>>
>> Charles Moulliard
>> Senior Enterprise Architect
>> Apache Camel Committer
>>
>> *****************************
>> blog : http://cmoulliard.blogspot.com
>>
>>
>>
>> On Mon, Sep 21, 2009 at 2:12 PM, Claus Ibsen <[email protected]> wrote:
>>> On Mon, Sep 21, 2009 at 2:05 PM, Charles Moulliard <[email protected]>
>>> wrote:
>>>> @EndpointInject(uri="") only accepts as parameter an uri / name or
>>>> context but not a reference to a spring bean
>>>>
>>>
>>> Its the name attribute that is the ref, maybe we should rename it :)
>>>
>>>
>>>
>>>> Charles Moulliard
>>>> Senior Enterprise Architect
>>>> Apache Camel Committer
>>>>
>>>> *****************************
>>>> blog : http://cmoulliard.blogspot.com
>>>>
>>>>
>>>>
>>>> On Mon, Sep 21, 2009 at 1:59 PM, Claus Ibsen <[email protected]> wrote:
>>>>> On Mon, Sep 21, 2009 at 1:55 PM, Charles Moulliard <[email protected]>
>>>>> wrote:
>>>>>> Sorry for my mistake.
>>>>>>
>>>>>> I have used @consume because it was possible to pass as a parameter
>>>>>> the name of the endpoint to consume. Is there a way to do this with a
>>>>>> consumer template ?
>>>>>>
>>>>>
>>>>> You can IoC the endpoint in the bean
>>>>>
>>>>> @EndpointInjected(ref = "foo")
>>>>> private Endpoint foo;
>>>>>
>>>>> but I would assume consumer template also works like producer template
>>>>> with IoC
>>>>> ( if not we should add it)
>>>>>
>>>>> @EndpointInjected(ref = "foo")
>>>>> private ConsumerTemplate consumer;
>>>>>
>>>>>
>>>>> See more
>>>>> http://camel.apache.org/bean-injection.html
>>>>>
>>>>>> regards,
>>>>>>
>>>>>> Charles Moulliard
>>>>>> Senior Enterprise Architect
>>>>>> Apache Camel Committer
>>>>>>
>>>>>> *****************************
>>>>>> blog : http://cmoulliard.blogspot.com
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Mon, Sep 21, 2009 at 1:50 PM, Claus Ibsen <[email protected]>
>>>>>> wrote:
>>>>>>> On Mon, Sep 21, 2009 at 1:46 PM, Charles Moulliard
>>>>>>> <[email protected]> wrote:
>>>>>>>> The POJO defined in the following route consumes immediately messages
>>>>>>>> posted on a queue and in consequence is not triggered by the Quartz
>>>>>>>> timer
>>>>>>>>
>>>>>>>> <camel:from
>>>>>>>> uri="quartz://x3sReporting/clientError?cron=0+0/5+9-18+?+*+MON-FRI"/>
>>>>>>>> <camel:doTry>
>>>>>>>> <camel:bean ref="reportingConsumer"
>>>>>>>> method="collectMessages"/>
>>>>>>>> ...
>>>>>>>>
>>>>>>>> public class ReportingConsumer {
>>>>>>>>
>>>>>>>> �...@consume(ref = "queueReportingEndpoint") // = x3s:report queue
>>>>>>>> public List<Map<String, Object>>
>>>>>>>> collectMessages(List<Map<String,
>>>>>>>> Object>> received) {
>>>>>>>>
>>>>>>>> List<Map<String, Object>> result = new ArrayList<Map<String,
>>>>>>>> Object>>();
>>>>>>>>
>>>>>>>> if (received != null) {
>>>>>>>>
>>>>>>>> Log.info("Received exchange : " +
>>>>>>>> received.size());
>>>>>>>> for(Map<String, Object> model : received) {
>>>>>>>>
>>>>>>>> Log.info("Map received : " +
>>>>>>>> model.toString());
>>>>>>>> // Add model received into the result
>>>>>>>> output list
>>>>>>>> result.add( model );
>>>>>>>> }
>>>>>>>> }
>>>>>>>>
>>>>>>>> return result;
>>>>>>>> }
>>>>>>>>
>>>>>>>> Question : How can I avoid that the bean consumes immediately messages
>>>>>>>> from the queue and wait quartz triggering ?
>>>>>>>
>>>>>>> You cannot as @Consume(ref = "queueReportingEndpoint") has ABSOLUTELY
>>>>>>> nothing to do with quartz.
>>>>>>> It creates a new event driven consumer which listen on new messages
>>>>>>> arriving on that JMS queue.
>>>>>>>
>>>>>>> You can remove the @Consume and then let quartz invoke it from the
>>>>>>> Camel route.
>>>>>>>
>>>>>>> And then you can in your bean use a consumer template to read messages
>>>>>>> from the JMS queue.
>>>>>>> Now you bean is only invoked when quartz triggers.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>>
>>>>>>>> Charles Moulliard
>>>>>>>> Senior Enterprise Architect
>>>>>>>> Apache Camel Committer
>>>>>>>>
>>>>>>>> *****************************
>>>>>>>> blog : http://cmoulliard.blogspot.com
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Claus Ibsen
>>>>>>> Apache Camel Committer
>>>>>>>
>>>>>>> Open Source Integration: http://fusesource.com
>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>> Twitter: http://twitter.com/davsclaus
>>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Claus Ibsen
>>>>> Apache Camel Committer
>>>>>
>>>>> Open Source Integration: http://fusesource.com
>>>>> Blog: http://davsclaus.blogspot.com/
>>>>> Twitter: http://twitter.com/davsclaus
>>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> Claus Ibsen
>>> Apache Camel Committer
>>>
>>> Open Source Integration: http://fusesource.com
>>> Blog: http://davsclaus.blogspot.com/
>>> Twitter: http://twitter.com/davsclaus
>>>
>>
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
>