+49 228 5552576-0


info@predic8.com

Tutorial: Deployment within Apache ServiceMix 7

This tutorial takes about 10 minutes. It demonstrates how a Membrane service proxy configuration file (proxies.xml) can be directly deployed into Apache ServiceMix 7 running Karaf (or any OSGi container, for that matter).

Warning: This tutorial is a work in progress and will work with Membrane Service Proxy 4.2.2 or newer when completed

ServiceMix 7 is a state of the art Enterprise Service Bus that provides OSGi bundles for asynchronous messaging, SOAP and EAI patterns. Membrane ESB can add to ServiceMix powerful, yet simple to use functionality for HTTP-, REST- and SOAP-based Web Services.

Membrane can also provide HTTP routing and integration at high speeds for a ServiceMix installation.

1. Get Apache ServiceMix running

Download and install JDK 8.

Download Apache ServiceMix 7.0.0.M2 or newer and unpack it.

Make sure your JAVA_HOME environment variable is set and points to the JDK: For example, edit bin\servicemix.bat and add

set "JAVA_HOME=C:\Program Files\Java\jdk1.8.0_91"
at the very top. Save it and start bin\servicemix.bat.

(For more information about setting up ServiceMix, read the ServiceMix documentation.)

You should now see the Karaf shell:

karaf@root> _

If you run Windows, increase the width of the console window to at least 140. (Karaf has problems with input commands wider than the console window. You can resize the window by right-clicking the window title and choosing Properties and then the Layout tab.)

2. Deploy com.predic8.membrane.osgi.extender

Run the following command to install the Membrane OSGi extender:

karaf@root> feature:repo-add https://raw.github.com/membrane/service-proxy/master/osgi-extender/src/main/xml/membrane-feature.xml
karaf@root> feature:install membrane
karaf@root> _

Once the Membrane feature is started, the OSGi platform is able to recognize bundles containing Membrane configuration files.

3. Create a Proxy Configuration File

Now create a file called proxies.xml somewhere on your computer containing the following content: (Use the left icon shown when hovering for Copy&Paste.)

<?xml version="1.0" encoding="UTF-8"?>
<blue:blueprint
	xmlns="http://membrane-soa.org/proxies/1/"
	xmlns:blue="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://membrane-soa.org/proxies/1/
      http://membrane-soa.org/schemas/proxies-1.xsd">
      
    <router hotDeploy="false">
    
   		<serviceProxy name="Console" port="9000">
			<adminConsole/>
		</serviceProxy>
		 
		<serviceProxy port="2000">
			<target host="membrane-soa.org" />
		</serviceProxy>
		
    </router>
</blue:blueprint>;

When you are done, move this file into the ...\deploy\ subdirectory where you unpacked ServiceMix.

The configuration file is now automatically processed: Using the command

karaf@root> bundle:list -t 60
[ 188] [Active ] [ ] [ ] [ 60] Membrane OSGi Blueprint Extender (4.2.2)
karaf@root> _

you can inspect what happened: The file proxies.xml was turned into an OSGi bundle which was installed and activated.

4. Watch the First Result

Open http://localhost:2000/ in a browser and watch.

Also visit the admin console.

5. Modify the Configuration File

Open ...\deploy\proxies.xml and change the target from membrane-soa.org to google.com or your favorite website. Save the file.

Wait a few seconds (about 2 on modern hardware) for the system to pick up the change.

Now refresh http://localhost:2000/ in the browser.

For the log file use:

karaf@root> log:display
karaf@root> log:clear
karaf@root> _

6. Final Comments

In proxies.xml you can use any Membrane feature, for example add password authentication. The configuration elements are all described in the reference.

If you want to extend Membrane with your own functionality, you can implement your own "interceptor" for Membrane. Doing that using Eclipse and Maven is only slightly more complicated than this tutorial. To get started, you can follow the next tutorial.

Copyright © 2008-2017 predic8 GmbH
Koblenzerstr. 65, 53173 Bonn, Tel. +49 (228) 555 25 76-0