camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgavlin <rgav...@yahoo.com>
Subject Re: Best Practices for Triggering Routes from Code
Date Fri, 04 Dec 2009 22:21:00 GMT

Actually, I wanted to know how to start it from the same jvm using OSGi. Any
thoughts on this?

/Ron


Claus Ibsen-2 wrote:
> 
> On Fri, Dec 4, 2009 at 5:45 AM, rgavlin <rgavlin@yahoo.com> wrote:
>>
>> Hi Claus,
>>
>> Let's say I have a camel route that begins with from("nmr:...") deployed
>> as
>> an OSGi bundle in the upcoming SMX 4.1. Within a Camel route in another
>> OSGi
>> bundle I would like to lookup and then start the first route. Is it
>> possible
>> to use the OSGi Registry to perform such a lookup? If yes, do you have
>> any
>> examples of doing so?
>>
> 
> Not out of the box as staring a route is done from the CamelContext
> and thus you need to do that using the CamelContext which owns the
> route.
> So starting from another JVM is not possible.
> 
> You can however use JMX to do this as you can invoke operations from
> one JVM to another.
> 
> You could use a JMS topic that each CamelContext has a build in route
> who listen on and then you can send "commands" to all or specific
> camel contexts.
> And maybe in the future we could add such a feature to Camel itself.
> As it probably makes sense to manage such routes / flows more dynamic
> and without the hazzle from JMX.
> 
> 
> 
>> Thanks,
>>
>> /Ron
>>
>>
>>
>> Claus Ibsen-2 wrote:
>>>
>>> On Thu, Dec 3, 2009 at 1:32 AM, mumbly <mcnerney@gmail.com> wrote:
>>>>
>>>> I'm talking about on demand triggering. Basically, I want to be able to
>>>> trigger a route programatically from within my code. I'm using quartz
>>>> already for certain batch processing. I'm just trying to understand how
>>>> the
>>>> items I listed differ, whether they are the set you'd want to use for
>>>> on
>>>> demand triggering and whether the ProducerTemplate is the right way to
>>>> go
>>>> about that.
>>>>
>>>
>>> Its easier in 2.1 as you can create routes which aren't started when
>>> Camel starts
>>> http://camel.apache.org/configuring-route-startup-ordering-and-autostartup.html
>>>
>>> And you can assign the route an id using .routeId in Java DSL or just
>>> "id" attribute in XML.
>>>
>>> Then you can manually start that route from JMX, Java code etc.
>>>
>>> CamelContext context = ...
>>>
>>> context.startRoute("theIdOfYourRoute");
>>>
>>> context.stopRoute("theIdOfYourRoute");
>>>
>>>
>>>
>>>
>>>> --Tim
>>>>
>>>>
>>>> Dragisa Krsmanovic wrote:
>>>>>
>>>>> It depends what you mean by 'triggering'.
>>>>>
>>>>> If you want to automatically send a message to a queue at specific
>>>>> intervals you can use Quartz component.
>>>>>
>>>>> For example, to send a "Hello World" message every 3 minutes:
>>>>>
>>>>> from("quartz://myCron?cron=0+0/3+*+*+*+?")
>>>>> .setBody(constant("Hello World"))
>>>>> .to(destination);
>>>>>
>>>>> Where destination can be anything ("direct:myQueue",
>>>>> "activemq:myQueue"
>>>>> etc.)
>>>>>
>>>>>
>>>>>
>>>>> On Wed, 2009-12-02 at 14:00 -0800, mumbly wrote:
>>>>>> While many of our processes are triggered by some external event
>>>>>> (timer,
>>>>>> file
>>>>>> transfers, emails, web/REST/SOAP requests), there are a number of
>>>>>> instances
>>>>>> where we want to trigger a route from within our code. I'm trying
to
>>>>>> understand how Camel allows me to do this and what the recommended
>>>>>> practices/patterns for this type of interaction are.
>>>>>>
>>>>>> I see a handful of components which seem like they would meet the
>>>>>> criteria
>>>>>> for trigger, but I'm not clear on which I should use. Basically I'm
>>>>>> looking
>>>>>> at:
>>>>>>
>>>>>> * direct
>>>>>> * jms
>>>>>> * seda
>>>>>> * vm
>>>>>>
>>>>>> It seems to me like they are similar, but it is unclear which are
>>>>>> best
>>>>>> under
>>>>>> what conditions. Is there some document comparing the pros and cons
>>>>>> and
>>>>>> potential use cases for these transports in non-test circumstances?
>>>>>>
>>>>>> And is the general pattern of direct triggering to use a
>>>>>> ProducerTemplate?
>>>>>> It felt a bit like this was mainly for testing, but I don't see other
>>>>>> methods used in the examples (or for that matter, I don't recall
>>>>>> seeing
>>>>>> ProducerTemplate in non-test code, though I haven't searched too
>>>>>> closely).
>>>>>>
>>>>>> Basically, just trying to get some guidance as to the recommended
>>>>>> practice.
>>>>>>
>>>>>> Thanks.
>>>>>>
>>>>>> --Tim
>>>>>
>>>>>
>>>>> --
>>>>> Dragisa Krsmanovic
>>>>> Java Developer
>>>>> Public Library of Science
>>>>> http://www.plos.org
>>>>>
>>>>>
>>>>> --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>>>>> This email is confidential to the intended recipient. If you have
>>>>> received
>>>>> it in error, please notify the sender and delete it from your system.
>>>>> Any
>>>>> unauthorized use, disclosure or copying is not permitted. The views or
>>>>> opinions presented are solely those of the sender and do not
>>>>> necessarily
>>>>> represent those of Public Library of Science unless otherwise
>>>>> specifically
>>>>> stated. Please note that neither Public Library of Science nor any of
>>>>> its
>>>>> agents accept any responsibility for any viruses that may be contained
>>>>> in
>>>>> this e-mail or its attachments and it is your responsibility to scan
>>>>> the
>>>>> e-mail and attachments (if any).
>>>>>
>>>>>
>>>>>
>>>>
>>>> --
>>>> View this message in context:
>>>> http://old.nabble.com/Best-Practices-for-Triggering-Routes-from-Code-tp26617252p26619145.html
>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> Claus Ibsen
>>> Apache Camel Committer
>>>
>>> Author of Camel in Action: http://www.manning.com/ibsen/
>>> Open Source Integration: http://fusesource.com
>>> Blog: http://davsclaus.blogspot.com/
>>> Twitter: http://twitter.com/davsclaus
>>>
>>>
>>
>> --
>> View this message in context:
>> http://old.nabble.com/Best-Practices-for-Triggering-Routes-from-Code-tp26617252p26635764.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> Claus Ibsen
> Apache Camel Committer
> 
> Author of Camel in Action: http://www.manning.com/ibsen/
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
> 
> 

-- 
View this message in context: http://old.nabble.com/Best-Practices-for-Triggering-Routes-from-Code-tp26617252p26642545.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Mime
View raw message