You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Viswanath Durbha <Vi...@gmail.com> on 2007/11/19 13:09:50 UTC

Reload Java EIP Rules

Hi,

I'm using ActiveMQ 5.0 snapshot version that has Camel integrated. I've
defined some Camel EIP routes using Java. I created a jar and dropped it
into the $ACTIVEMQ_HOME/lib folder. All the routes I've defined in there
work perfectly fine.

However, if I want to change any of those routes, can I do that without
restarting the broker itself? If I just drop a new jar file, would it be
picked up by the current broker instance automatically? Or is there any
other way to do it?
-- 
View this message in context: http://www.nabble.com/Reload-Java-EIP-Rules-tf4835861s2354.html#a13834840
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Reload Java EIP Rules

Posted by James Strachan <ja...@gmail.com>.
On 20/11/2007, James Strachan <ja...@gmail.com> wrote:
> On 20/11/2007, James Strachan <ja...@gmail.com> wrote:
> > On 20/11/2007, Rob Davies <ra...@gmail.com> wrote:
> > > ActiveMQ 5 requires Java 5 - so this won't be a problem for AgentSmth
> > > We just need to override the Smith.redefineClass() method in a
> > > derived class to add some eventing to stop the routes and reload the
> > > classes
> >
> > That should work! :)
> >
> > If it doesn't - or we hit some limitation of AgentSmith (e.g. I've
> > seen talk of AgentSmith not reloading stuff if you add new methods or
> > fields to a class), I guess we could always build our own little
> > reloading classloader thingy?
> >
> > e.g. we could do something like this in camel...
> >
> > <camelContext>
> >   <rules dir="lib/rules" package="org.foo"/>
> > </camelContext>
> >
> > which would then create a single ClassLoader for all the *.jar files
> > in that directory and then load and activate all the rules in there.
> >
> > If any of the jars change, we could stop all those rules, ditch the
> > classloader and reload all the jars again and re-activate the rules
> > again.
> >
> > I guess AgentSmith might be more clever and realise just which rules
> > have actually changed maybe? I wonder if eclipse has any clever
> > hot-swap ninja we could reuse?
>
> I was chatting with Guillaume on IRC and he mentioned this lovely
> looking tool...
> http://www.aqute.biz/Code/FileInstall
>
> which can monitor a directory for OSGi bundles (jars really) and
> install+start then stop+uninstall & reload things if the jars change.
>
> So I guess one neat solution could be to allow ActiveMQ to boot up an
> OSGi container (say Felix) with spring+osgi and FileInstall installed.
> Then if Java routing rules were put into OSGi bundles (i.e. a jar with
> the OSGi metadata), spring-osgi should auto-boot up the bundle and
> activate the routing rules when the jar loads - and stop the routing
> rules when the bundle is stopped & uninstalled.
>
> It'd be nice if we could get the FileInstall to also allow any
> spring.xml to be added to the deploy directory & for it to be
> reloaded; then folks could just drop in routing rules as spring.xml
> files; or edit them to have things reload. i.e. kinda treating any
> spring.xml file as a kinda bundle with no Java code :)

Just to tie up the loose ends here - the ServiceMix 4 Runtime is
coming together nicely!

It supports the hot-redeployment of OSGi bundles; so Camel routes get
auto-redeployed. Plus there's an expanded OSGi bundle format; so you
can edit a Spring XML or change a Java class inside a bundle (via just
editing the files directly) and the runtime will auto-reload the OSGi
bundle giving fast reload of any Camel routing rules.
http://cwiki.apache.org/SMX4/runtime.html

So the only thing we need is to convert the ActiveMQ broker itself to
use the ServiceMix 4 Runtime to deploy/run itself and we're good to
go.

-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com

Re: Reload Java EIP Rules

Posted by James Strachan <ja...@gmail.com>.
On 20/11/2007, James Strachan <ja...@gmail.com> wrote:
> On 20/11/2007, Rob Davies <ra...@gmail.com> wrote:
> > ActiveMQ 5 requires Java 5 - so this won't be a problem for AgentSmth
> > We just need to override the Smith.redefineClass() method in a
> > derived class to add some eventing to stop the routes and reload the
> > classes
>
> That should work! :)
>
> If it doesn't - or we hit some limitation of AgentSmith (e.g. I've
> seen talk of AgentSmith not reloading stuff if you add new methods or
> fields to a class), I guess we could always build our own little
> reloading classloader thingy?
>
> e.g. we could do something like this in camel...
>
> <camelContext>
>   <rules dir="lib/rules" package="org.foo"/>
> </camelContext>
>
> which would then create a single ClassLoader for all the *.jar files
> in that directory and then load and activate all the rules in there.
>
> If any of the jars change, we could stop all those rules, ditch the
> classloader and reload all the jars again and re-activate the rules
> again.
>
> I guess AgentSmith might be more clever and realise just which rules
> have actually changed maybe? I wonder if eclipse has any clever
> hot-swap ninja we could reuse?

I was chatting with Guillaume on IRC and he mentioned this lovely
looking tool...
http://www.aqute.biz/Code/FileInstall

which can monitor a directory for OSGi bundles (jars really) and
install+start then stop+uninstall & reload things if the jars change.

So I guess one neat solution could be to allow ActiveMQ to boot up an
OSGi container (say Felix) with spring+osgi and FileInstall installed.
Then if Java routing rules were put into OSGi bundles (i.e. a jar with
the OSGi metadata), spring-osgi should auto-boot up the bundle and
activate the routing rules when the jar loads - and stop the routing
rules when the bundle is stopped & uninstalled.

It'd be nice if we could get the FileInstall to also allow any
spring.xml to be added to the deploy directory & for it to be
reloaded; then folks could just drop in routing rules as spring.xml
files; or edit them to have things reload. i.e. kinda treating any
spring.xml file as a kinda bundle with no Java code :)

-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com

Re: Reload Java EIP Rules

Posted by ttmdev <jo...@ttmsolutions.com>.
Might want to take a look at Tomcat's reloading classloader thingy ;)

Tomcat's reloading classloader redeploys a web application on the fly if
certain parts (e.g., context descriptor, war, web.xml, etc.) change. 
   


James.Strachan wrote:
> 
> On 20/11/2007, Rob Davies <ra...@gmail.com> wrote:
>> ActiveMQ 5 requires Java 5 - so this won't be a problem for AgentSmth
>> We just need to override the Smith.redefineClass() method in a
>> derived class to add some eventing to stop the routes and reload the
>> classes
> 
> That should work! :)
> 
> If it doesn't - or we hit some limitation of AgentSmith (e.g. I've
> seen talk of AgentSmith not reloading stuff if you add new methods or
> fields to a class), I guess we could always build our own little
> reloading classloader thingy?
> 
> e.g. we could do something like this in camel...
> 
> <camelContext>
>   <rules dir="lib/rules" package="org.foo"/>
> </camelContext>
> 
> which would then create a single ClassLoader for all the *.jar files
> in that directory and then load and activate all the rules in there.
> 
> If any of the jars change, we could stop all those rules, ditch the
> classloader and reload all the jars again and re-activate the rules
> again.
> 
> I guess AgentSmith might be more clever and realise just which rules
> have actually changed maybe? I wonder if eclipse has any clever
> hot-swap ninja we could reuse?
> 
> -- 
> James
> -------
> http://macstrac.blogspot.com/
> 
> Open Source Integration
> http://open.iona.com
> 
> 

-- 
View this message in context: http://www.nabble.com/Reload-Java-EIP-Rules-tf4835861s2354.html#a13856964
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Reload Java EIP Rules

Posted by James Strachan <ja...@gmail.com>.
On 20/11/2007, Rob Davies <ra...@gmail.com> wrote:
> ActiveMQ 5 requires Java 5 - so this won't be a problem for AgentSmth
> We just need to override the Smith.redefineClass() method in a
> derived class to add some eventing to stop the routes and reload the
> classes

That should work! :)

If it doesn't - or we hit some limitation of AgentSmith (e.g. I've
seen talk of AgentSmith not reloading stuff if you add new methods or
fields to a class), I guess we could always build our own little
reloading classloader thingy?

e.g. we could do something like this in camel...

<camelContext>
  <rules dir="lib/rules" package="org.foo"/>
</camelContext>

which would then create a single ClassLoader for all the *.jar files
in that directory and then load and activate all the rules in there.

If any of the jars change, we could stop all those rules, ditch the
classloader and reload all the jars again and re-activate the rules
again.

I guess AgentSmith might be more clever and realise just which rules
have actually changed maybe? I wonder if eclipse has any clever
hot-swap ninja we could reuse?

-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com

Re: Reload Java EIP Rules

Posted by Rob Davies <ra...@gmail.com>.
ActiveMQ 5 requires Java 5 - so this won't be a problem for AgentSmth
We just need to override the Smith.redefineClass() method in a  
derived class to add some eventing to stop the routes and reload the  
classes



cheers,

Rob

http://open.iona.com/ -Enterprise Open Integration
http://rajdavies.blogspot.com/



On Nov 20, 2007, at 4:39 AM, Viswanath Durbha wrote:

>
> Here's what I read about AgentSmith.
>
> 1. It has an implementation of the  
> java.lang.instrument.Instrumentation
> interface and it also has a file monitor.
> 2. It has the ability to monitor predefined list of folders for  
> changes to
> classes. It can also monitor jar files.
> 3. It needs atleast Java 5 to run.
>
> There are a couple of problems that need to be addressed if we want  
> to use
> this tool in ActiveMQ.
> 1. There doesn't seem to be any event notification mechanism built  
> into
> this. So this tool will automatically reload the classes as soon as it
> identifies them as changed. So there is no mechanism by which we  
> can stop
> our routes and then reload our classes, and then start the routes  
> again.
> 2. It needs atleast Java 5 to run. I assume that we are planning to  
> have
> this feature as part of 5.1.0 release of ActiveMQ. What JVM version  
> is the
> minimum required for 5.1.0? If it has to run on 1.4.2, then Agent  
> Smith is
> not an option for us.
>
> Please let me know your thoughts.
>
>
> James.Strachan wrote:
>>
>> On 19/11/2007, Viswanath Durbha <Vi...@gmail.com> wrote:
>>>
>>> Thanks for the quick response.
>>>
>>> I was looking at both JavaRebel and AgentSmith. JavaRebel seems  
>>> to have a
>>> very restrictive license agreement which may never fit into the  
>>> Apache
>>> License of ActiveMQ.
>>>
>>> AgentSmith looks promising and it uses Apache License 2.0. I  
>>> would look
>>> into
>>> it and see if I can contribute to this issue in any way.
>>
>> Awesome! I feel we might need to kinda listen to Class objects being
>> reloaded, so we could tell the CamelContext to stop a route for a
>> RouteBuilder and start another one etc. I've not looked into Agent
>> Smith to see if its got some kinda notification
>>
>>
>>> I just started using ActiveMQ and I feel it's fantastic. I hope I  
>>> can get
>>> familiar enough with it so that I can contribute.
>>
>> Great - I hope so too! :)
>> -- 
>> James
>> -------
>> http://macstrac.blogspot.com/
>>
>> Open Source Integration
>> http://open.iona.com
>>
>>
>
> -- 
> View this message in context: http://www.nabble.com/Reload-Java-EIP- 
> Rules-tf4835861s2354.html#a13850813
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>


Re: Reload Java EIP Rules

Posted by Viswanath Durbha <Vi...@gmail.com>.
Here's what I read about AgentSmith.

1. It has an implementation of the java.lang.instrument.Instrumentation
interface and it also has a file monitor.
2. It has the ability to monitor predefined list of folders for changes to
classes. It can also monitor jar files.
3. It needs atleast Java 5 to run.

There are a couple of problems that need to be addressed if we want to use
this tool in ActiveMQ.
1. There doesn't seem to be any event notification mechanism built into
this. So this tool will automatically reload the classes as soon as it
identifies them as changed. So there is no mechanism by which we can stop
our routes and then reload our classes, and then start the routes again.
2. It needs atleast Java 5 to run. I assume that we are planning to have
this feature as part of 5.1.0 release of ActiveMQ. What JVM version is the
minimum required for 5.1.0? If it has to run on 1.4.2, then Agent Smith is
not an option for us.

Please let me know your thoughts.


James.Strachan wrote:
> 
> On 19/11/2007, Viswanath Durbha <Vi...@gmail.com> wrote:
>>
>> Thanks for the quick response.
>>
>> I was looking at both JavaRebel and AgentSmith. JavaRebel seems to have a
>> very restrictive license agreement which may never fit into the Apache
>> License of ActiveMQ.
>>
>> AgentSmith looks promising and it uses Apache License 2.0. I would look
>> into
>> it and see if I can contribute to this issue in any way.
> 
> Awesome! I feel we might need to kinda listen to Class objects being
> reloaded, so we could tell the CamelContext to stop a route for a
> RouteBuilder and start another one etc. I've not looked into Agent
> Smith to see if its got some kinda notification
> 
> 
>> I just started using ActiveMQ and I feel it's fantastic. I hope I can get
>> familiar enough with it so that I can contribute.
> 
> Great - I hope so too! :)
> -- 
> James
> -------
> http://macstrac.blogspot.com/
> 
> Open Source Integration
> http://open.iona.com
> 
> 

-- 
View this message in context: http://www.nabble.com/Reload-Java-EIP-Rules-tf4835861s2354.html#a13850813
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Reload Java EIP Rules

Posted by James Strachan <ja...@gmail.com>.
On 19/11/2007, Viswanath Durbha <Vi...@gmail.com> wrote:
>
> Thanks for the quick response.
>
> I was looking at both JavaRebel and AgentSmith. JavaRebel seems to have a
> very restrictive license agreement which may never fit into the Apache
> License of ActiveMQ.
>
> AgentSmith looks promising and it uses Apache License 2.0. I would look into
> it and see if I can contribute to this issue in any way.

Awesome! I feel we might need to kinda listen to Class objects being
reloaded, so we could tell the CamelContext to stop a route for a
RouteBuilder and start another one etc. I've not looked into Agent
Smith to see if its got some kinda notification


> I just started using ActiveMQ and I feel it's fantastic. I hope I can get
> familiar enough with it so that I can contribute.

Great - I hope so too! :)
-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com

Re: Reload Java EIP Rules

Posted by Viswanath Durbha <Vi...@gmail.com>.
Thanks for the quick response.

I was looking at both JavaRebel and AgentSmith. JavaRebel seems to have a
very restrictive license agreement which may never fit into the Apache
License of ActiveMQ.

AgentSmith looks promising and it uses Apache License 2.0. I would look into
it and see if I can contribute to this issue in any way.

I just started using ActiveMQ and I feel it's fantastic. I hope I can get
familiar enough with it so that I can contribute.


James.Strachan wrote:
> 
> On 19/11/2007, Viswanath Durbha <Vi...@gmail.com> wrote:
>>
>> Hi,
>>
>> I'm using ActiveMQ 5.0 snapshot version that has Camel integrated. I've
>> defined some Camel EIP routes using Java. I created a jar and dropped it
>> into the $ACTIVEMQ_HOME/lib folder. All the routes I've defined in there
>> work perfectly fine.
>>
>> However, if I want to change any of those routes, can I do that without
>> restarting the broker itself? If I just drop a new jar file, would it be
>> picked up by the current broker instance automatically? Or is there any
>> other way to do it?
> 
> Currently today the only option is to bounce the broker unfortunately.
> Though on the plus side; if you're clients are using failover: then
> things will just work even if you bounce the broker.
> 
> You can always deploy the EIP routes in another process; so bouncing
> it doesn't affect the broker.
> 
> To avoid bouncing the broker we could experiment with using JavaRebel...
> http://www.zeroturnaround.com/javarebel/
> 
> to auto-detect class changes and redeploying them. Another option is
> Agent Smith that does a similar thing...
> https://agentsmith.dev.java.net/
> 
> We'd just need to figure out a way to ensure that if a RouteBuilder
> class is changed, we correctly remove the old one (shutting down the
> route) and re-applying the new one.
> 
> I've created an issue to track this...
> https://issues.apache.org/activemq/browse/AMQ-1495
> 
> -- 
> James
> -------
> http://macstrac.blogspot.com/
> 
> Open Source Integration
> http://open.iona.com
> 
> 

-- 
View this message in context: http://www.nabble.com/Reload-Java-EIP-Rules-tf4835861s2354.html#a13839275
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Reload Java EIP Rules

Posted by James Strachan <ja...@gmail.com>.
On 19/11/2007, Viswanath Durbha <Vi...@gmail.com> wrote:
>
> Hi,
>
> I'm using ActiveMQ 5.0 snapshot version that has Camel integrated. I've
> defined some Camel EIP routes using Java. I created a jar and dropped it
> into the $ACTIVEMQ_HOME/lib folder. All the routes I've defined in there
> work perfectly fine.
>
> However, if I want to change any of those routes, can I do that without
> restarting the broker itself? If I just drop a new jar file, would it be
> picked up by the current broker instance automatically? Or is there any
> other way to do it?

Currently today the only option is to bounce the broker unfortunately.
Though on the plus side; if you're clients are using failover: then
things will just work even if you bounce the broker.

You can always deploy the EIP routes in another process; so bouncing
it doesn't affect the broker.

To avoid bouncing the broker we could experiment with using JavaRebel...
http://www.zeroturnaround.com/javarebel/

to auto-detect class changes and redeploying them. Another option is
Agent Smith that does a similar thing...
https://agentsmith.dev.java.net/

We'd just need to figure out a way to ensure that if a RouteBuilder
class is changed, we correctly remove the old one (shutting down the
route) and re-applying the new one.

I've created an issue to track this...
https://issues.apache.org/activemq/browse/AMQ-1495

-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com