camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: POJO consumer and Quartz
Date Mon, 21 Sep 2009 12:12:00 GMT
On Mon, Sep 21, 2009 at 2:05 PM, Charles Moulliard <cmoulliard@gmail.com> 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 <claus.ibsen@gmail.com> wrote:
>> On Mon, Sep 21, 2009 at 1:55 PM, Charles Moulliard <cmoulliard@gmail.com> 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 <claus.ibsen@gmail.com> wrote:
>>>> On Mon, Sep 21, 2009 at 1:46 PM, Charles Moulliard <cmoulliard@gmail.com>
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

Mime
View raw message