Hi Yeah for spring xml I would look into either using the spring's bridge property placeholder, and then implement your database lookup as if it was a pure spring problem, and how to integrate that with spring's property placeholder magic.
An alternative is the Camel way and implement a custom org.apache.camel.component.properties.PropertiesResolver and have it extend the default resolver, if you need the regular ones as well, eg to load .properties files from classpath/file etc. And then define a <bean id="properties" class="org.apache.camel.component.properties.PropertiesComponent"> and configure it to use your custom resolver class. Though I would like to make that even easier so you would just define your custom <bean> for the resolver, and have Camel's properties component auto lookup and use yours as well out of the box. Like we can do for: https://camel.apache.org/advanced-configuration-of-camelcontext-using-spring.html And we have a few JIRA tickets already logged to improve the Camel's properties component. On Wed, Apr 23, 2014 at 8:51 AM, kraythe . <[email protected]> wrote: > Greetings, I am currently using java DSL and have been investigating Fuse > and Fabric8 as possible alternatives. Currently I have a route that does > something like the following: > > final String cron = > this.config.automationCasesDBMonitorCron().replaceAll(" ", "+"); > final String quartzURI = > "quartz://case_automation/processAutomationCasesFromDB?cron=" + cron; > fromStandard(quartzURI) > .routeId(ROUTE_ID_ETL_MONITOR_TIMER) // timer trigger > .transacted(TxnHelper.KEY_TXNPOLICY_REQUIRED) // make the route > transacted > .to(InOnly, endpointAMQ(this.config.queueETLCheckEvent())); // put > an event to be consumed > > As you can see, I fetch the names of queues and cron trigger configs from a > configuration object. The actual config class goes to a database to get the > configuration but that is not relevant to the question. The question is how > can I implement something like this inside the spring DSL (which I am > admittedly unfamiliar with). Currently I am trying to cross code my routes > and for this one I have the following: > > <camelContext xmlns="http://camel.apache.org/schema/spring"> > <route id="ETLMonitorTimer"> > <from > uri="quartz://case_automation/processAutomationCasesFromDB?cron="/> > <transacted ref="REQUIRED"/> > <to uri="activemq:queue:"/> > </route> > </camelContext> > > As you can see I don't have the cron trigger or the destination queue that > I get normally from the config file so I am at a bit of a loss as to how to > accomplish this. I was thinking with a property placeholder i could do > something like this: > > <bean id="configBean" class="com.foo.ConfigMgr"/> > <camelContext xmlns="http://camel.apache.org/schema/spring"> > <propertyPlaceholder ref="configBean"/> > > <route id="ETLMonitorTimer"> > <from > uri="quartz://case_automation/processAutomationCasesFromDB?cron={{etl_monitor_cron}}"/> > <transacted ref="REQUIRED"/> > <to uri="activemq:queue:{{event_queue}}"/> > </route> > </camelContext> > > But I may be way off base on how to do that. I confess I have always > thought the Spring XML DSL to be much less flexible and powerful than the > Java DSL but I am open to being proven wrong. :) > > So any help here? Thanks a bunch. > > *Robert Simmons Jr. MSc. - Lead Java Architect @ EA* > *Author of: Hardcore Java (2003) and Maintainable Java (2012)* > *LinkedIn: **http://www.linkedin.com/pub/robert-simmons/40/852/a39 > <http://www.linkedin.com/pub/robert-simmons/40/852/a39>* -- Claus Ibsen ----------------- Red Hat, Inc. Email: [email protected] Twitter: davsclaus Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen hawtio: http://hawt.io/ fabric8: http://fabric8.io/
