Search code examples
apache-camelapache-servicemix

Servicemix/Camel : how to leverage OSGI to create "pluggable" bundles?


Scenario : I'll try to put an analogy with the loan broker example from the EIP book

  1. The customer sends a quote request
  2. (The loan broker requests customer credit score from the credit bureau)
  3. The loan broker sends quote requests to each bank.

The problem

  • In my case point 1 and 2 are in the same camel context (or osgi bundle)
  • Each bank has a separate bundle, exposing endpoints to the loan-broker-bundle through NMR
  • loan-broker-bundle doesn't know about the banks beforehand since we keep partnering with new banks every now and then

What I did

  • Created a registry class and a bankDescriptor interface in loan-broker-bundle
  • each bank bundle when started calls the registery to add its bankDescriptor (spring init) that tells the loan broker what endpoint to call to get a quote.
  • loan-broker-bundle main route uses recipientList (a processor sets target endpoints by asking the registery) to route quote requests

The question

Hoping my description was clear enough, you can see that this is a really simple implementation. What are its limits ? How can i turn this registery into an osgi service ?


Solution

  • I developed a solution like this based on SpringDM for a client. There's a full write up of how to do this at http://www.jakubkorab.net/2012/05/system-integrations-as-plugins-using-camel-and-servicemix.html with full source code available at https://github.com/FuseByExample/smx-application-plugins

    Hope that helps.