Struggling to deploy custom RouteBuilder in ActiveMQ 4.1.1

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Struggling to deploy custom RouteBuilder in ActiveMQ 4.1.1

DominicTulley
Hi, I'm hoping someone can point me in the right direction here.

I'm trying to write my own RouteBuilder (java class, extends RouteBuilder) and then use it within a CamelContext hosted in ActiveMQ 4.1.1.  I've had "static routing" working using camelcontext elements in activemq.xml but I can't persuade it to load and configure a RouteBuilder implementation.

So far I have a dead simple RouteBuilder:

=====================================
package org.dominic

import org.apache.camel.builder.RouteBuilder;

public class DomsRouteBuilder extends RouteBuilder  {
   public DomsRouteBuilder()   {
      System.out.println("\n*\n*\n*\n*\n*\n*\nDomsRouter instantiated");
   }

   public void configure()   {
      System.out.println("*\n*\n*\n*\nConfiguring Route Builder");
   };
}

==========================

I compile this and put it in a jar file which I dump in ActiveMQ's lib directory.

Next I modify activemq.xml and add

=====================
  <camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring" packages="org.dominic">
</camelContext>
=====================

After this, I hope to start ActiveMQ and see my strings get printed out but I see nothing...

I have gone further than this (putting in a proper route that forwards from one queue to another) but I have cut the example right down for this post since I believe I have a deployment problem.   Turning on full debugging in ActiveMQ gives no mention of my class name at all - I'm guessing it just isn't being picked up for some reason.

I'm using what was the latest 1.1 build (built on 10 August) although I think a nightly build from today has appeared now.  I could drop down to the 1.0 release if this looks like an issue with 1.1 (I realise it's early days for 1.1 still) but I do need one of the bug fixes which is in 1.1 ultimately.

Any suggestions gratefully received!

Thanks,

-Dominic
Reply | Threaded
Open this post in threaded view
|

Re: Struggling to deploy custom RouteBuilder in ActiveMQ 4.1.1

Hiram Chirino
Camel has only been integrated in to the the up coming ActiveMQ 5.x
version.. If you want, try a snapshot build from here:

http://people.apache.org/repo/m2-snapshot-repository/org/apache/activemq/apache-activemq/5.0-SNAPSHOT/

On 8/13/07, DominicTulley <[hidden email]> wrote:

>
> Hi, I'm hoping someone can point me in the right direction here.
>
> I'm trying to write my own RouteBuilder (java class, extends RouteBuilder)
> and then use it within a CamelContext hosted in ActiveMQ 4.1.1.  I've had
> "static routing" working using camelcontext elements in activemq.xml but I
> can't persuade it to load and configure a RouteBuilder implementation.
>
> So far I have a dead simple RouteBuilder:
>
> =====================================
> package org.dominic
>
> import org.apache.camel.builder.RouteBuilder;
>
> public class DomsRouteBuilder extends RouteBuilder  {
>    public DomsRouteBuilder()   {
>       System.out.println("\n*\n*\n*\n*\n*\n*\nDomsRouter instantiated");
>    }
>
>    public void configure()   {
>       System.out.println("*\n*\n*\n*\nConfiguring Route Builder");
>    };
> }
>
> ==========================
>
> I compile this and put it in a jar file which I dump in ActiveMQ's lib
> directory.
>
> Next I modify activemq.xml and add
>
> =====================
>   <camelContext id="camel"
> xmlns="http://activemq.apache.org/camel/schema/spring"
> packages="org.dominic">
> </camelContext>
> =====================
>
> After this, I hope to start ActiveMQ and see my strings get printed out but
> I see nothing...
>
> I have gone further than this (putting in a proper route that forwards from
> one queue to another) but I have cut the example right down for this post
> since I believe I have a deployment problem.   Turning on full debugging in
> ActiveMQ gives no mention of my class name at all - I'm guessing it just
> isn't being picked up for some reason.
>
> I'm using what was the latest 1.1 build (built on 10 August) although I
> think a nightly build from today has appeared now.  I could drop down to the
> 1.0 release if this looks like an issue with 1.1 (I realise it's early days
> for 1.1 still) but I do need one of the bug fixes which is in 1.1
> ultimately.
>
> Any suggestions gratefully received!
>
> Thanks,
>
> -Dominic
> --
> View this message in context: http://www.nabble.com/Struggling-to-deploy-custom-RouteBuilder-in-ActiveMQ-4.1.1-tf4261073s22882.html#a12125795
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>


--
Regards,
Hiram

Blog: http://hiramchirino.com
Reply | Threaded
Open this post in threaded view
|

Re: Struggling to deploy custom RouteBuilder in ActiveMQ 4.1.1

jstrachan
On 8/13/07, Hiram Chirino <[hidden email]> wrote:
> Camel has only been integrated in to the the up coming ActiveMQ 5.x
> version.. If you want, try a snapshot build from here:
>
> http://people.apache.org/repo/m2-snapshot-repository/org/apache/activemq/apache-activemq/5.0-SNAPSHOT/

If you want to try Camel inside the ActiveMQ 4.1.1, broker you'd have
to add the camel jars to the lib directory; along with the jaxb API &
impl jars (and StAX too). Or as Hiram says, just try ActiveMQ 5.x
which has Camel integrated into the broker.

--
James
-------
http://macstrac.blogspot.com/
Reply | Threaded
Open this post in threaded view
|

Re: Struggling to deploy custom RouteBuilder in ActiveMQ 4.1.1

DominicTulley
In reply to this post by Hiram Chirino
Hi Hiram, I had read that Camel was being integrated into ActiveMQ 5 but I also found instructions for using it with 4.1.1 (just dumping a bunch of libraries into the lib and optional directories).  This seems to work for route definitions done in the activemq.xml file.  My understanding was that the integration with version 5 was really just that the libraries were being bundled by default - but perhaps it's a tighter integration than that.

Do you know it won't work with 4.1.1, or are you just suggesting I stand a better chance using 5?

Thanks,

-Dominic

Reply | Threaded
Open this post in threaded view
|

Re: Struggling to deploy custom RouteBuilder in ActiveMQ 4.1.1

DominicTulley
In reply to this post by Hiram Chirino
Since setting up ActiveMQ is so easy, I've tried this with ActiveMQ 5's latest build as well now, sadly with the same result.
There's just no sign of my class getting instantiated or invoked at any point.

Any other ideas?  Normally my next step would be to step through the startup and observe the context loading - but that sounds like a lot of hard work and I'm not particularly familiar with any of the tools involved (never mind their source code).  I'm assuming that I've just done something daft, but if not I guess I'll have to do it the hard way..

Thanks,

-Dominic


Hiram Chirino wrote
Camel has only been integrated in to the the up coming ActiveMQ 5.x
version.. If you want, try a snapshot build from here:

http://people.apache.org/repo/m2-snapshot-repository/org/apache/activemq/apache-activemq/5.0-SNAPSHOT/

On 8/13/07, DominicTulley <dominic.tulley@telelogic.com> wrote:
>
> Hi, I'm hoping someone can point me in the right direction here.
>
> I'm trying to write my own RouteBuilder (java class, extends RouteBuilder)
> and then use it within a CamelContext hosted in ActiveMQ 4.1.1.  I've had
> "static routing" working using camelcontext elements in activemq.xml but I
> can't persuade it to load and configure a RouteBuilder implementation.
>
> So far I have a dead simple RouteBuilder:
>
> =====================================
> package org.dominic
>
> import org.apache.camel.builder.RouteBuilder;
>
> public class DomsRouteBuilder extends RouteBuilder  {
>    public DomsRouteBuilder()   {
>       System.out.println("\n*\n*\n*\n*\n*\n*\nDomsRouter instantiated");
>    }
>
>    public void configure()   {
>       System.out.println("*\n*\n*\n*\nConfiguring Route Builder");
>    };
> }
>
> ==========================
>
> I compile this and put it in a jar file which I dump in ActiveMQ's lib
> directory.
>
> Next I modify activemq.xml and add
>
> =====================
>   <camelContext id="camel"
> xmlns="http://activemq.apache.org/camel/schema/spring"
> packages="org.dominic">
> </camelContext>
> =====================
>
> After this, I hope to start ActiveMQ and see my strings get printed out but
> I see nothing...
>
> I have gone further than this (putting in a proper route that forwards from
> one queue to another) but I have cut the example right down for this post
> since I believe I have a deployment problem.   Turning on full debugging in
> ActiveMQ gives no mention of my class name at all - I'm guessing it just
> isn't being picked up for some reason.
>
> I'm using what was the latest 1.1 build (built on 10 August) although I
> think a nightly build from today has appeared now.  I could drop down to the
> 1.0 release if this looks like an issue with 1.1 (I realise it's early days
> for 1.1 still) but I do need one of the bug fixes which is in 1.1
> ultimately.
>
> Any suggestions gratefully received!
>
> Thanks,
>
> -Dominic
> --
> View this message in context: http://www.nabble.com/Struggling-to-deploy-custom-RouteBuilder-in-ActiveMQ-4.1.1-tf4261073s22882.html#a12125795
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>


--
Regards,
Hiram

Blog: http://hiramchirino.com
Reply | Threaded
Open this post in threaded view
|

Re: Struggling to deploy custom RouteBuilder in ActiveMQ 4.1.1

jstrachan
On 8/13/07, DominicTulley <[hidden email]> wrote:
> Since setting up ActiveMQ is so easy, I've tried this with ActiveMQ 5's
> latest build as well now, sadly with the same result.
> There's just no sign of my class getting instantiated or invoked at any
> point.
>
> Any other ideas?

So to include Java routes in the broker in ActiveMQ 5 you'll need to
refer to your parent package name in the  Camel XML...

<camelContext>
  <package>com.acme.whatever</package>
   ...
</camelContext>

Then you'll need to make sure that the jar containing your routes is
in the lib directory.

Incidentally one minor change from Camel 1.0 to 1.1 is that its moved
from an attribute 'packages' to an element 'package' (which you can
include 0..N of them). Maybe thats the thing thats causing your issue?


> Normally my next step would be to step through the startup
> and observe the context loading - but that sounds like a lot of hard work
> and I'm not particularly familiar with any of the tools involved (never mind
> their source code).  I'm assuming that I've just done something daft, but if
> not I guess I'll have to do it the hard way..

FWIW if ever you wanna startup the code for an ActiveMQ broker in an
IDE or something you can use

java -jar run.jar

which basically just sets up the classpath to include all the jars in
the lib directory etc.
--
James
-------
http://macstrac.blogspot.com/