Excellent, thanks the sample. That helps a lot! On Mon, Jun 13, 2016 at 7:55 PM, Quinn Stevenson [via Camel] < ml-node+s465427n5783979...@n5.nabble.com> wrote:
> Here’s a very simple sample. > > Given a route builder: > > public class SimpleBuilder extends RouteBuilder { > String timerName = "simple-timer"; > int timerPeriod = 5000; > int timerDelay = 1000; > > @Override > public void configure() throws Exception { > fromF( "timer://%s?timerPeriod=%d&timerDelay=%d", timerName, > timerPeriod, timerDelay) > .log( "Timer fired"); > } > > public String getTimerName() { > return timerName; > } > > public void setTimerName(String timerName) { > this.timerName = timerName; > } > > public int getTimerPeriod() { > return timerPeriod; > } > > public void setTimerPeriod(int timerPeriod) { > this.timerPeriod = timerPeriod; > } > > public int getTimerDelay() { > return timerDelay; > } > > public void setTimerDelay(int timerDelay) { > this.timerDelay = timerDelay; > } > } > > You can create multiple blueprints to deploy it - here’s a sample of one > <?xml version="1.0" encoding="UTF-8"?> > <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xmlns:cm=" > http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0" > xsi:schemaLocation=" > http://www.osgi.org/xmlns/blueprint/v1.0.0 > http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd > http://camel.apache.org/schema/blueprint > http://camel.apache.org/schema/blueprint/camel-blueprint.xsd"> > > <cm:property-placeholder id="simple-consumer-properties" > persistent-id="SimpleConsumer" update-strategy="reload"> > <cm:default-properties> > <cm:property name="timerName" value="camel-consumer"/> > <cm:property name="timerPeriod" value="15000"/> > <cm:property name="timerDelay" value="5000"/> > </cm:default-properties> > </cm:property-placeholder> > > <bean id="simple-route" > class="com.pronoia.camel.builder.SimpleBuilder"> > <property name="timerName" value="${timerName}" /> > <property name="timerPeriod" value="${timerPeriod}" /> > <property name="timerDelay" value="${timerDelay}" /> > </bean> > > <camelContext id="simple-context" xmlns=" > http://camel.apache.org/schema/blueprint"> > <routeBuilder ref="simple-route"/> > </camelContext> > > </blueprint> > > You can use different persistent id’s so you can dynamically configure the > builders. If you don’t need the dynamic configuration capability, you can > configure the properties directly in the bean configuration like in the > following blueprint. > <?xml version="1.0" encoding="UTF-8"?> > <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation=" > http://www.osgi.org/xmlns/blueprint/v1.0.0 > http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd > http://camel.apache.org/schema/blueprint > http://camel.apache.org/schema/blueprint/camel-blueprint.xsd"> > > <bean id="another-simple-route" > class="com.pronoia.camel.builder.SimpleBuilder"> > <property name="timerName" value="another-timer" /> > <property name="timerPeriod" value="30000" /> > <property name="timerDelay" value="15000" /> > </bean> > > <camelContext id="another-context" xmlns=" > http://camel.apache.org/schema/blueprint"> > <routeBuilder ref="another-simple-route"/> > </camelContext> > > </blueprint> > > You can either put the blueprints in a bundle and deploy the bundles, or > put the blueprints directly in the $KARAF_HOME/deploy folder. > > Is that what you’re looking for? > > > On Jun 10, 2016, at 3:01 PM, souciance <[hidden email] > <http:///user/SendEmail.jtp?type=node&node=5783979&i=0>> wrote: > > > > Hi Joseph, > > > > Thanks for the input. Do you have an example blueprint for the actual > > declaration of the multiple bean instances? > > > > Thanks > > Souciance > > > > On Fri, Jun 10, 2016 at 9:33 PM, Joseph E. Kampf Jr. [via Camel] < > > [hidden email] <http:///user/SendEmail.jtp?type=node&node=5783979&i=1> > <mailto:[hidden email] > <http:///user/SendEmail.jtp?type=node&node=5783979&i=2>>> wrote: > > > >> We do this all the time. This is simple dependency injection. > >> > >> We create a RouteBuilder class that has endpoints, processors, data > >> formats and aggregators injected. Any parameter to the Java DSL can be > >> injected, including bean reference and bean instances. > >> > >> Then we create multiple bean instances of this RouteBuilder, and then > add > >> them as routeBuilder refs in the Camel Context. > >> > >> We also inject the Route ID so that we can differentiate the route in > >> Hawtio. > >> > >> Joe Kampf > >> > >> > >> > >> > >> > >> On 6/10/16, 9:28 AM, "souciance" <[hidden email] > >> <http:///user/SendEmail.jtp?type=node&node=5783892&i=0 < > http://user/SendEmail.jtp?type=node&node=5783892&i=0>>> wrote: > >> > >>> Hello, > >>> > >>> Are there any good places to read or examples to see, of how to build > >>> generic camel routes? For example: > >>> > >>> I have 10 routes which differ only in their endpoints and some headers > >> and > >>> processors. > >>> > >>> I would like to create a generic route and have the endpoint URI and > >> other > >>> parameters injected and hence have multiple instances of the route to > be > >>> created with the different endpoints. Is this possible to do? Are > there > >> any > >>> drawbacks to this approach e.g. for testing? > >>> > >>> Best > >>> Souciance > >>> > >>> > >>> > >>> -- > >>> View this message in context: > >> > http://camel.465427.n5.nabble.com/Generic-camel-routes-multiple-instances-tp5783866.html > >>> Sent from the Camel - Users mailing list archive at Nabble.com. > >> > >> > >> > >> ------------------------------ > >> If you reply to this email, your message will be added to the > discussion > >> below: > >> > >> > http://camel.465427.n5.nabble.com/Generic-camel-routes-multiple-instances-tp5783866p5783892.html > < > http://camel.465427.n5.nabble.com/Generic-camel-routes-multiple-instances-tp5783866p5783892.html> > > >> To start a new topic under Camel - Users, email > >> [hidden email] <http:///user/SendEmail.jtp?type=node&node=5783979&i=3> > <mailto:[hidden email] > <http:///user/SendEmail.jtp?type=node&node=5783979&i=4>> > >> To unsubscribe from Generic camel routes - multiple instances, click > here > >> < href="" target="_top" rel="nofollow" link="external"> > >> . > >> NAML > >> < > http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml > < > http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>> > > >> > > > > > > > > > > -- > > View this message in context: > http://camel.465427.n5.nabble.com/Generic-camel-routes-multiple-instances-tp5783866p5783898.html > < > http://camel.465427.n5.nabble.com/Generic-camel-routes-multiple-instances-tp5783866p5783898.html> > > > Sent from the Camel - Users mailing list archive at Nabble.com < > http://nabble.com/>. > > > > ------------------------------ > If you reply to this email, your message will be added to the discussion > below: > > http://camel.465427.n5.nabble.com/Generic-camel-routes-multiple-instances-tp5783866p5783979.html > To start a new topic under Camel - Users, email > ml-node+s465427n465428...@n5.nabble.com > To unsubscribe from Generic camel routes - multiple instances, click here > <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5783866&code=c291Y2lhbmNlLmVxZGFtLnJhc2h0aUBnbWFpbC5jb218NTc4Mzg2NnwxNTMyOTExNjU2> > . > NAML > <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml> > -- View this message in context: http://camel.465427.n5.nabble.com/Generic-camel-routes-multiple-instances-tp5783866p5783983.html Sent from the Camel - Users mailing list archive at Nabble.com.