2

Our project is using Apache Camel, with FuseESB and we are also utilizing Spring. Right now we have a handful of property files that we define when we build the project (with Maven).

We want to move the property files to an external file that will be on each system (dev/qa/prod) and use that as the property file.

I'm trying to figure out how I am going to do this. There is more of course but this is relevant to the question I believe. I was looking at the Camel documentation but I'm still a little bit confused on how to go about this.

I was looking at this post at the question, and it seemed that I want to use that type of configuration but in my Spring xml file.

I just need some general guidance with this, Thanks!

Community
  • 1
  • 1
Envin
  • 1,463
  • 8
  • 32
  • 69
  • I think I'm able to share some experiences on this, but first may I ask - are you using a `blueprint.xml` in your project? Otherwise how are you configuring your camel routes. – vikingsteve Jun 18 '13 at 13:23
  • We are using a blueprint, we called it camel-context.xml but it has in it. All it is doing is Creating a controller bean and exporting it to the service registry (per the comments). Edited main post and added it. – Envin Jun 18 '13 at 14:30

2 Answers2

2

For external configuration you want to be looking at OSGI cm property-placeholders;

There is some information about this here

To override the default properties defined within your cm:property-placeholder block you provide an external file which matches the unique persistent-id attribute value you provided with a file type of '.cfg'.

If you are wanting to deploy to Karaf for instance; Then this config will be dropped into ${KARAF_HOME}/etc/yourPID.cfg

This capability is provided with both Spring DM and Blueprint

AlanFoster
  • 8,156
  • 5
  • 35
  • 52
  • Will this replace the propertyplaceholder in the spring xml file -- should I remove that part now? – Envin Jun 18 '13 at 20:56
  • You can check out my answer on the following thread. There's a fully detailed example. It uses Spring DM for property loading (easy way for doing this). This solution will extend your PropertyPlaceHolder with the properties found in OSGi. http://stackoverflow.com/questions/16984812/proxy-authentication-with-camel-using-producertemplate/16985136#16985136. – Gergely Kovács Jun 19 '13 at 08:12
  • @envinyater Also check out this link for Spring-DM http://static.springsource.org/osgi/docs/1.2.x/reference/html/compendium.html - But try to use Blueprint if possible :) – AlanFoster Jun 19 '13 at 08:26
1

You could also look at setting up a Fuse Fabric.

Instead of editing .cfg files manually, each server (container) in the fabric is configured with a specified profile. For example, myprofile-dev, myprofile-qa, myprofile-prod.

This will insert the properties (e.g. foo=bar) from the fabric profile right into the cm property-placeholders, and your blueprint configuration will be mostly the same as described by AlanFoster in his answer.

Here's some info on Fabric Profiles.

Especially if you are running many servers and environments, fabric profiles can be a nice way to manage deployment and configuration.

Note that I'm not completely sure how this solves your spring vs blueprint issue. I chose to do away with spring completely, and move all the DI & beans into blueprint, avoiding the spring vs blueprint conflict and leaving the configuration of properties exclusively in blueprint.

I'm not sure if you want to do away with spring or not - perhaps you would prefer to keep it, in which case can I suggest looking at the section Bridging Spring and Camel property holders down towards the bottom of the page at this link: Camel: Using Property Placeholder (haven't tried it myself, ymmv).

Good luck!

vikingsteve
  • 38,481
  • 23
  • 112
  • 156