2 Replies Latest reply on May 3, 2013 2:11 AM by Claus Ibsen

    Starting a Route with a paremeter via JMX

    Eric Bender Newbie

      Hello, I was wondering if I had a custom MBean I wanted to write which would have a parameter entered in via JMX, what would be the best way to start an existing route and pass it that parameter (via header or some other method).

        • 1. Re: Starting a Route with a paremeter via JMX
          Eric Bender Newbie

          Just for more information, if I had an MBean with an operation such as:


               public synchronized String doStuff(String theParam) {
                        //What goes here?


          And this would need to spawn an existing route such as:


                 <osgi:camelContext id="context1" xmlns=...>
                        <route id="route1">
                             <from uri="direct:theStart">
                             ....do stuff with the String parameter, header, etc...


          I just don't currently understand how I can feed a value form the bean to the route, as well as start the route.  I am guessing it is more obvious if I use a java routebuilder, but I am still hoping for some assistance in getting started.

          • 2. Re: Starting a Route with a paremeter via JMX
            Claus Ibsen Master

            Yeah XML is much harder because its not a programming language. So it depends really what you want to do with the parameters, if its possible to do.


            You can also put together a route in XML from java code and load the route from an input stream as shown here:



            Or have the route as a template in an XML file and then "replace" tokens from the XML file with the parameter, in some java code. And you would need a bit of java code anyway for the JMX operation.


            You can also use template langauges like Velocity / Freemarker to build the XML. They have "XML programming" as they have functions you can use in the template files.