Archive for the ‘servicemix’ Category


Developing web services in ServiceMix

I have added a number of projects to FuseByExample/smx-ws-examples on GitHub that demonstrate how to go about developing a number of common web service use cases. The samples are designed to get you up and running quickly with SOAP based web services in an OSGi world.

The examples include:

  • a Maven project that generates all relevant Java code from a WSDL using the cxf-codegen-plugin, and wraps it in an OSGi bundle
  • a plain Java web service implementation of a web service using CXF
  • an implementation of the web service using a Camel CXF route
  • a web service proxy using a Camel route
  • a client based on a Camel route that uses the CXF component to invoke those web services; no Java code required

As usual, full documentation in the README. Enjoy!

Build-time integration testing OSGi bundles in ServiceMix

I have just added a new project to GitHub under FuseByExample/smx-integration-testing that you can use to verify at build time that your bundles and features will deploy and run as expected in a specific version of ServiceMix. The intention is that you can use it to kick start testing in your own projects.

To do this I hooked up the process described by Ioannis Canellos in Advanced integration testing with Pax Exam Karaf to start up and deploy your project artifacts into an embedded FuseSource distribution of ServiceMix (4.4.1-fuse-01.13 at time of writing), using the maven-failsafe-plugin for integration testing.

The result is a build that compiles and assembles your bundle or features project, unit tests it, packages it up for installation and then integration tests the binary using pax-exam-karaf and JUnit.

If your bundle fails either to install into the embedded ServiceMix container, or fails any of the criteria defined in your integration test, the build will fail and the build artifact won’t end up being installed to your Maven repo.

The sample demonstrates:

  • the wiring required to assemble this approach in Maven
  • the separation of test artifacts for a SpringDM bundle into both unit and integration tests; abstracting out the OSGi bits for unit testing while ensuring ${} placeholders work, and
  • shows a number of ways to exercise the code in your bundle via:
    • straight Camel route testing
    • using the OSGi BundleContext to verify that a bundle is installed and active
    • checking that a SpringDM OSGi service is deployed via the @Inject mechanism

The documentation in the README file goes into full detail as to how this is achieved.

Enjoy!

Bootstrap Projects for Getting Started with ServiceMix 4

Over the Christmas break I cleaned up and published a set of Maven projects for getting started with ServiceMix 4.4.1+ into GitHub. I found myself reusing the same code for a number of activities, and figured it may be of broader use to others. You can find it under FuseByExample/smx-bootstraps.

smx-bootstraps contains within it a set of OSGI Blueprints (DI, based on the ideas behind Spring) bundles that exercise some of the core things that you will want to do with ServiceMix:

  • defining services in bundles that can be reused in other bundles
  • use Camel for writing integration code
  • use ActiveMQ for sending persistent messages between bundles, regardless of whether they are in the same container or in others
  • request-response over messaging
  • Update 20/02/2012: RESTful web services!!!
  • externalising your environment configuration
  • group bundles into features

The README document at the project root explains how to get started with ServiceMix, deploy bundles, change code and play with config.

Why would you want to use them?

ServiceMix went through a massive generational change between versions 3.X and 4.X, moving from JBI to an OSGi based model. While development work on it is proceeding at a huge rate, the documentation hasn’t kept up – although it is being brought up to date in the background. smx-bootstraps contains small artifacts that are hopefully easy to understand and play with, along with instructions on how to use them in the container.

The project may also be use of use as a starting starting point to further development. A fairly clean project layout exists that you can use as a reference point, which acts as a supplement to the Maven archetypes that are publicly available, such as:

  • org.apache.camel.archetypes:camel-archetype-blueprint for generating Blueprint bundles to run Camel routes; similar to smx-pinger and smx-ponger bundles in smx-bootstraps
  • org.apache.karaf.archetypes:karaf-blueprint-archetype for generating simple Blueprint bundles; such as the smx-ponger-service bundle

I have found these bundles to be a really handy way of exercising ServiceMix features, and working with various configurations. Not having to code up something new each time is a huge time saver. Hopefully you should find this as well.

I expect to expand this little project as time goes on and I find myself recreating other use cases, such as exposing web services – next on my “todo list”. Please drop me a line at “jakub dot korab at gmail” if you find this useful or have any ideas that would fit in well. Of course being GitHub, feel free to fork it or contribute back changes.