ServiceMix 4 Make the container match the project Gert Vanthienen r&d engineer anova r&d bvba [email_address]
Who am I? Gert Vanthienen (gert@anova.be) 10 years of technology r&d engineering Integrating open-source technology  Legacy integration with IBM i open-source activities Apache Camel, Felix and ServiceMix Committer Member of Progress' FUSE team
Goals Learn about ServiceMix 4.1 Functionality and use of Components  and sub-projects OSGi standards Learn how to build your own container Start with an empty Karaf instance Add elements you need for your project
Overview ServiceMix 3 to ServiceMix 4 ServiceMix 4 from the bottom up Apache Felix Karaf Apache ServiceMix NMR Apache ServiceMix JBI Wrap it up
Overview ServiceMix 3 to ServiceMix 4 ServiceMix 4 from the bottom up Apache Felix Karaf Apache ServiceMix NMR Apache ServiceMix JBI Wrap it up
ServiceMix 3 to ServiceMix 4 ServiceMix 3 JBI 1.0 container JBI Components 2009.0x ServiceMix 4 JBI 1.0 support built on top of OSGi The same set of JBI Components
 
 
Overview ServiceMix 3 to ServiceMix 4 ServiceMix 4 from the bottom up Apache Felix Karaf Apache ServiceMix NMR Apache ServiceMix JBI Wrap it up
 
Apache Felix Karaf Introducing Karaf How-to build a Camel container? Command shell Feature descriptors Hot-deployment A few more Karaf features
Apache Felix Karaf Introducing Karaf How-to build a Camel Container? Command shell Feature descriptors Hot-deployment A few more Karaf features
Introducing Karaf A flexible OSGi-based server runtime Choice of OSGi runtime: Apache Felix Eclipse Equinox Manage the container using: command shell  web console
Introducing Karaf Some other features Provisioning through feature descriptors Applications Spring DM and Blueprint Hot-deployment Manage child instances Failover using file or JDBC lock
Apache Felix Karaf Introducing Karaf Create Camel Container Command shell Feature descriptors Hot-deployment A few more Karaf features
Karaf: Command Shell Based on Apache Felix Gogo Implementation of OSGi RFC-147 Uses a <group>:<command> syntax Command shell can be accessed Directly when starting the container Using an SSH client TAB-completion, |, utilities like grep and cat
Karaf: Command Shell Install, start and list OSGi bundles karaf@root> osgi:install file:/Users/gert/restaurant-1.0.jar Bundle ID: 30 karaf@root> osgi:start 30 karaf@root> osgi:install -s mvn:org.tssjs.smx4/mexican/1.0 Bundle ID: 31 karaf@root> osgi:list | grep TSSJS  [  30] [Active  ] [  ] [  60] TSSJS :: Restaurant (1.0) [  31] [Active  ] [  ] [  60] TSSJS :: Kitchen :: Mexican (1.0) Logging karaf@root> log:get Level: INFO karaf@root> log:set DEBUG karaf@root> log:display Change settings through the OSGi ConfigAdmin   karaf@root> config:edit org.apache.felix.karaf.shell.ssh  karaf@root> config:propset sshPort 8100 karaf@root> config:update  …  and these are just a few examples
Karaf: Feature descriptors Default Karaf provisioning mechanism XML descriptor for installing software List of bundles to install Configuration information Dependencies between features
Karaf: Feature descriptors <? xml   version = &quot;1.0&quot;   encoding = &quot;UTF-8&quot; ?> < features   name = &quot;karaf-1.1.0-SNAPSHOT&quot; > < feature   name = &quot;http&quot;   version = &quot;1.1.0-SNAPSHOT&quot; > < config   name = &quot;org.ops4j.pax.web&quot; > org.osgi.service.http.port=8181 </ config > <!--  snip --> < bundle > mvn:org.ops4j.pax.web/pax-web-bundle/0.6.0 </ bundle > </ feature > < feature   name = &quot;webconsole&quot;   version = &quot;1.1.0-SNAPSHOT&quot; > < feature   version = &quot;1.1.0-SNAPSHOT&quot; > http </ feature > <!--  snip --> < bundle > mvn:org.apache.felix/org.apache.felix.webconsole/1.2.10 </ bundle > </ feature > </ features >
Karaf: Feature descriptors A feature can be installed Using command shell Using the web console karaf@root> features:install webconsole karaf@root> features:list State  Version  Name  Repository [uninstalled] [2.5.6.SEC01  ] spring  karaf-1.1.0-SNAPSHOT [uninstalled] [1.2.0  ] spring-dm  karaf-1.1.0-SNAPSHOT [installed  ] [1.1.0-SNAPSHOT] http  karaf-1.1.0-SNAPSHOT [installed  ] [1.1.0-SNAPSHOT] webconsole karaf-1.1.0-SNAPSHOT
Karaf: Feature descriptors What's available? Karaf provides a few basic features wrapper, webconsole, spring, spring-dm, ... ServiceMix 4.1 comes with NMR/JBI support and JBI components Features for ActiveMQ, CXF, Pax Web, ... Other projects Apache Camel: EIP-based integration framework Apache Sling: content-driven web framework
Karaf: Hot-deployment Hot-deployment based on Felix FileInstall Karaf supports deployment of  Bundles Expanded bundles XML files (Spring, Blueprint and feature) An extensible mechanism Spring XML files with Spring feature installed JBI artifacts with JBI feature installed WAR files with web feature installed
Karaf: Create a Camel container Create a Camel container Add features URL for Camel Install camel-osgi and camel-ftp karaf@root> features:addUrl    mvn:org.apache.camel.karaf/features/2.1-SNAPSHOT/xml/features karaf@root> features:install camel-o camel-ognl  camel-osgi karaf@root> features:install camel-osgi karaf@root> features:install camel-ftp
Karaf: Create a Camel container Deploy the route in a Spring XML <? xml   version = &quot;1.0&quot; ?> < beans   xmlns = &quot;http://www.springframework.org/schema/beans&quot; xmlns:xsi = &quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation = &quot; http://www.springframework.org/schema/beans  http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://camel.apache.org/schema/spring  http://camel.apache.org/schema/spring/camel-spring.xsd&quot; > < camelContext   xmlns = &quot;http://camel.apache.org/schema/spring&quot; > < route > < from   uri = &quot;ftp://ck@ftp.resto.eu/recipes?password=secret&quot; /> < to   uri = &quot;file:/home/recipes/in&quot; /> </ route > </ camelContext > </ beans >
Apache Felix Karaf Introducing Karaf How-to build a Camel container? Command shell Feature descriptors Hot-deployment A few more Karaf features
Karaf: Admin commands Karaf allows you to create child instances share the system directory (which holds the base bundles) each has its own etc, deploy, data, … automatically assigned a new ssh port
Karaf: Admin commands Create a test instance running the http service karaf@root> admin:create test Creating new instance on port 8102 at ... karaf@root> admin:start test karaf@root> admin:connect test Connecting to host localhost on port 8102 Connected karaf@test> features:install http karaf@test> ^D karaf@root> admin:list  Port  State  Pid  Name [ 8102] [Started ] [ 1000] test karaf@root> admin:stop test  karaf@root> admin:destroy test
Karaf: Blueprint Services OSGi standard for IoC/DI Inspired by Spring DM (is also the RI) We use Geronimo blueprint by default (and Spring DM is available as a feature) Features XML Configuration file Register beans as services in OSGi Service Registry Reference other service in OSGi Service Registry Extensible through custom namespaces
Karaf: Blueprint Services Blueprint is a first-class citizen in Karaf Installed by default  Used internally for Karaf/ServiceMix Hot-deployment Plain XML configuration files OSGI-INF/blueprint/*.xml in bundles Lifecycle states available in osgi:list
Karaf: Blueprint Services Starting a restaurant that needs a kitchen <? xml   version = &quot;1.0&quot; ?> < blueprint   xmlns = &quot;http://www.osgi.org/xmlns/blueprint/v1.0.0&quot; > < service   interface = &quot;org.tssjs.smx4.Restaurant&quot; > < bean   class = &quot;org.tssjs.smx4.impl.RestaurantImpl&quot; > < property   name = &quot;location&quot;   value = &quot;Prague&quot; /> < property   name = &quot;kitchen&quot;   ref = &quot;kitchenRef&quot; /> </ bean > </ service > < reference   id = &quot;kitchenRef&quot;   interface = &quot;org.tssjs.smx4.Kitchen&quot; /> </ blueprint >
Karaf: Blueprint Services Install bundles and check status karaf@resto> osgi:install -s mvn:org.tssjs.smx4/restaurant/1.0 Bundle ID: 30 karaf@resto> osgi:list | grep TSSJS [  30] [Active  ] [GracePeriod] [ 60] TSSJS :: Restaurant (1.0) karaf@resto> osgi:install -s mvn:org.tssjs.smx4/mexican/1.0  Bundle ID: 31 karaf@resto> osgi:list | grep TSSJS [  30] [Active  ] [Created  ] [ 60] TSSJS :: Restaurant (1.0) [  31] [Active  ] [Created  ] [ 60] TSSJS :: Kitchen :: Mexican (1.0)
Karaf: Web Console Installable as a feature Based on Felix Web Console A set of extra plugins for Karaf Admin plugin for managing instances Features plugin Gogo plugin
Karaf: Web Console
Karaf: Web Console
 
ServiceMix 4 NMR easy to use messaging API (Exchange, Message, Endpoint, ...) ‏ handles XML and POJO payloads listener interfaces to monitor the NMR (ExchangeListener, EndpointListener, …) ‏ support for wiring endpoints and intercepting exchanges command shell for managing the NMR
ServiceMix NMR installable as a Karaf feature You can use it for loosely coupled integration Camel routes CXF web services …  add anything else yourself here We use it to build our JBI integration layer
ServiceMix NMR < beans  xmlns = &quot;http://www.springframework.org/schema/beans&quot;    xmlns:xsi = &quot;http://www.w3.org/2001/XMLSchema-instance&quot;  xsi:schemaLocation = &quot;...&quot; > < import  resource = &quot;classpath:org/apache/servicemix/camel/nmr/camel-nmr.xml&quot;  /> < camelContext  xmlns = &quot;http://camel.apache.org/schema/spring&quot; > < route > < from  uri = &quot;ftp://ck@ftp.resto.eu/recipes?password=secret&quot; /> < to  uri = &quot;nmr:Recipes&quot; /> </ route > <!-- the second route can be in another bundle/xml file --> < route >   < from  uri = &quot;nmr:Recipes&quot; />   < to  uri = &quot;file:/home/recipes/in&quot; /> </ route > </ camelContext > </ beans >
 
ServiceMix JBI Support for JBI 1.0 Installable in Karaf as a feature  JBI 1.0 API JBI Deployment and packaging JBI Management MBeans Improvements over ServiceMix 3.x New cluster engine implementation OSGi packaging
Overview ServiceMix 3 to ServiceMix 4 ServiceMix 4 from the bottom up Apache Felix Karaf Apache ServiceMix NMR Apache ServiceMix JBI Wrap it up
Wrap it up ServiceMix 4 OSGi container with support for JBI 1.0 Option 1: Use the full package Ideal when migrating existing JBI applications Option 2: Build your own container Start with Karaf and turn it into an - integration server with Camel and CXF - OSGi app server with web console and blueprint - web application server with ActiveMQ for JMS - …
References Interested? Want to get involved? Apache Felix Karaf http://felix.apache.org/site/apache-felix-karaf.html [email_address] Apache ServiceMix http://servicemix.apache.org [email_address]
Questions
Session Evaluation Please complete a session evaluation and turn it into any conference staff member or at the registration desk.  Thank you.

Gert Vanthienen Presentation

  • 1.
    ServiceMix 4 Makethe container match the project Gert Vanthienen r&d engineer anova r&d bvba [email_address]
  • 2.
    Who am I?Gert Vanthienen (gert@anova.be) 10 years of technology r&d engineering Integrating open-source technology Legacy integration with IBM i open-source activities Apache Camel, Felix and ServiceMix Committer Member of Progress' FUSE team
  • 3.
    Goals Learn aboutServiceMix 4.1 Functionality and use of Components and sub-projects OSGi standards Learn how to build your own container Start with an empty Karaf instance Add elements you need for your project
  • 4.
    Overview ServiceMix 3to ServiceMix 4 ServiceMix 4 from the bottom up Apache Felix Karaf Apache ServiceMix NMR Apache ServiceMix JBI Wrap it up
  • 5.
    Overview ServiceMix 3to ServiceMix 4 ServiceMix 4 from the bottom up Apache Felix Karaf Apache ServiceMix NMR Apache ServiceMix JBI Wrap it up
  • 6.
    ServiceMix 3 toServiceMix 4 ServiceMix 3 JBI 1.0 container JBI Components 2009.0x ServiceMix 4 JBI 1.0 support built on top of OSGi The same set of JBI Components
  • 7.
  • 8.
  • 9.
    Overview ServiceMix 3to ServiceMix 4 ServiceMix 4 from the bottom up Apache Felix Karaf Apache ServiceMix NMR Apache ServiceMix JBI Wrap it up
  • 10.
  • 11.
    Apache Felix KarafIntroducing Karaf How-to build a Camel container? Command shell Feature descriptors Hot-deployment A few more Karaf features
  • 12.
    Apache Felix KarafIntroducing Karaf How-to build a Camel Container? Command shell Feature descriptors Hot-deployment A few more Karaf features
  • 13.
    Introducing Karaf Aflexible OSGi-based server runtime Choice of OSGi runtime: Apache Felix Eclipse Equinox Manage the container using: command shell web console
  • 14.
    Introducing Karaf Someother features Provisioning through feature descriptors Applications Spring DM and Blueprint Hot-deployment Manage child instances Failover using file or JDBC lock
  • 15.
    Apache Felix KarafIntroducing Karaf Create Camel Container Command shell Feature descriptors Hot-deployment A few more Karaf features
  • 16.
    Karaf: Command ShellBased on Apache Felix Gogo Implementation of OSGi RFC-147 Uses a <group>:<command> syntax Command shell can be accessed Directly when starting the container Using an SSH client TAB-completion, |, utilities like grep and cat
  • 17.
    Karaf: Command ShellInstall, start and list OSGi bundles karaf@root> osgi:install file:/Users/gert/restaurant-1.0.jar Bundle ID: 30 karaf@root> osgi:start 30 karaf@root> osgi:install -s mvn:org.tssjs.smx4/mexican/1.0 Bundle ID: 31 karaf@root> osgi:list | grep TSSJS [ 30] [Active ] [ ] [ 60] TSSJS :: Restaurant (1.0) [ 31] [Active ] [ ] [ 60] TSSJS :: Kitchen :: Mexican (1.0) Logging karaf@root> log:get Level: INFO karaf@root> log:set DEBUG karaf@root> log:display Change settings through the OSGi ConfigAdmin karaf@root> config:edit org.apache.felix.karaf.shell.ssh karaf@root> config:propset sshPort 8100 karaf@root> config:update … and these are just a few examples
  • 18.
    Karaf: Feature descriptorsDefault Karaf provisioning mechanism XML descriptor for installing software List of bundles to install Configuration information Dependencies between features
  • 19.
    Karaf: Feature descriptors<? xml version = &quot;1.0&quot; encoding = &quot;UTF-8&quot; ?> < features name = &quot;karaf-1.1.0-SNAPSHOT&quot; > < feature name = &quot;http&quot; version = &quot;1.1.0-SNAPSHOT&quot; > < config name = &quot;org.ops4j.pax.web&quot; > org.osgi.service.http.port=8181 </ config > <!-- snip --> < bundle > mvn:org.ops4j.pax.web/pax-web-bundle/0.6.0 </ bundle > </ feature > < feature name = &quot;webconsole&quot; version = &quot;1.1.0-SNAPSHOT&quot; > < feature version = &quot;1.1.0-SNAPSHOT&quot; > http </ feature > <!-- snip --> < bundle > mvn:org.apache.felix/org.apache.felix.webconsole/1.2.10 </ bundle > </ feature > </ features >
  • 20.
    Karaf: Feature descriptorsA feature can be installed Using command shell Using the web console karaf@root> features:install webconsole karaf@root> features:list State Version Name Repository [uninstalled] [2.5.6.SEC01 ] spring karaf-1.1.0-SNAPSHOT [uninstalled] [1.2.0 ] spring-dm karaf-1.1.0-SNAPSHOT [installed ] [1.1.0-SNAPSHOT] http karaf-1.1.0-SNAPSHOT [installed ] [1.1.0-SNAPSHOT] webconsole karaf-1.1.0-SNAPSHOT
  • 21.
    Karaf: Feature descriptorsWhat's available? Karaf provides a few basic features wrapper, webconsole, spring, spring-dm, ... ServiceMix 4.1 comes with NMR/JBI support and JBI components Features for ActiveMQ, CXF, Pax Web, ... Other projects Apache Camel: EIP-based integration framework Apache Sling: content-driven web framework
  • 22.
    Karaf: Hot-deployment Hot-deploymentbased on Felix FileInstall Karaf supports deployment of Bundles Expanded bundles XML files (Spring, Blueprint and feature) An extensible mechanism Spring XML files with Spring feature installed JBI artifacts with JBI feature installed WAR files with web feature installed
  • 23.
    Karaf: Create aCamel container Create a Camel container Add features URL for Camel Install camel-osgi and camel-ftp karaf@root> features:addUrl mvn:org.apache.camel.karaf/features/2.1-SNAPSHOT/xml/features karaf@root> features:install camel-o camel-ognl camel-osgi karaf@root> features:install camel-osgi karaf@root> features:install camel-ftp
  • 24.
    Karaf: Create aCamel container Deploy the route in a Spring XML <? xml version = &quot;1.0&quot; ?> < beans xmlns = &quot;http://www.springframework.org/schema/beans&quot; xmlns:xsi = &quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation = &quot; http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd&quot; > < camelContext xmlns = &quot;http://camel.apache.org/schema/spring&quot; > < route > < from uri = &quot;ftp://ck@ftp.resto.eu/recipes?password=secret&quot; /> < to uri = &quot;file:/home/recipes/in&quot; /> </ route > </ camelContext > </ beans >
  • 25.
    Apache Felix KarafIntroducing Karaf How-to build a Camel container? Command shell Feature descriptors Hot-deployment A few more Karaf features
  • 26.
    Karaf: Admin commandsKaraf allows you to create child instances share the system directory (which holds the base bundles) each has its own etc, deploy, data, … automatically assigned a new ssh port
  • 27.
    Karaf: Admin commandsCreate a test instance running the http service karaf@root> admin:create test Creating new instance on port 8102 at ... karaf@root> admin:start test karaf@root> admin:connect test Connecting to host localhost on port 8102 Connected karaf@test> features:install http karaf@test> ^D karaf@root> admin:list Port State Pid Name [ 8102] [Started ] [ 1000] test karaf@root> admin:stop test karaf@root> admin:destroy test
  • 28.
    Karaf: Blueprint ServicesOSGi standard for IoC/DI Inspired by Spring DM (is also the RI) We use Geronimo blueprint by default (and Spring DM is available as a feature) Features XML Configuration file Register beans as services in OSGi Service Registry Reference other service in OSGi Service Registry Extensible through custom namespaces
  • 29.
    Karaf: Blueprint ServicesBlueprint is a first-class citizen in Karaf Installed by default Used internally for Karaf/ServiceMix Hot-deployment Plain XML configuration files OSGI-INF/blueprint/*.xml in bundles Lifecycle states available in osgi:list
  • 30.
    Karaf: Blueprint ServicesStarting a restaurant that needs a kitchen <? xml version = &quot;1.0&quot; ?> < blueprint xmlns = &quot;http://www.osgi.org/xmlns/blueprint/v1.0.0&quot; > < service interface = &quot;org.tssjs.smx4.Restaurant&quot; > < bean class = &quot;org.tssjs.smx4.impl.RestaurantImpl&quot; > < property name = &quot;location&quot; value = &quot;Prague&quot; /> < property name = &quot;kitchen&quot; ref = &quot;kitchenRef&quot; /> </ bean > </ service > < reference id = &quot;kitchenRef&quot; interface = &quot;org.tssjs.smx4.Kitchen&quot; /> </ blueprint >
  • 31.
    Karaf: Blueprint ServicesInstall bundles and check status karaf@resto> osgi:install -s mvn:org.tssjs.smx4/restaurant/1.0 Bundle ID: 30 karaf@resto> osgi:list | grep TSSJS [ 30] [Active ] [GracePeriod] [ 60] TSSJS :: Restaurant (1.0) karaf@resto> osgi:install -s mvn:org.tssjs.smx4/mexican/1.0 Bundle ID: 31 karaf@resto> osgi:list | grep TSSJS [ 30] [Active ] [Created ] [ 60] TSSJS :: Restaurant (1.0) [ 31] [Active ] [Created ] [ 60] TSSJS :: Kitchen :: Mexican (1.0)
  • 32.
    Karaf: Web ConsoleInstallable as a feature Based on Felix Web Console A set of extra plugins for Karaf Admin plugin for managing instances Features plugin Gogo plugin
  • 33.
  • 34.
  • 35.
  • 36.
    ServiceMix 4 NMReasy to use messaging API (Exchange, Message, Endpoint, ...) ‏ handles XML and POJO payloads listener interfaces to monitor the NMR (ExchangeListener, EndpointListener, …) ‏ support for wiring endpoints and intercepting exchanges command shell for managing the NMR
  • 37.
    ServiceMix NMR installableas a Karaf feature You can use it for loosely coupled integration Camel routes CXF web services … add anything else yourself here We use it to build our JBI integration layer
  • 38.
    ServiceMix NMR <beans xmlns = &quot;http://www.springframework.org/schema/beans&quot; xmlns:xsi = &quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation = &quot;...&quot; > < import resource = &quot;classpath:org/apache/servicemix/camel/nmr/camel-nmr.xml&quot; /> < camelContext xmlns = &quot;http://camel.apache.org/schema/spring&quot; > < route > < from uri = &quot;ftp://ck@ftp.resto.eu/recipes?password=secret&quot; /> < to uri = &quot;nmr:Recipes&quot; /> </ route > <!-- the second route can be in another bundle/xml file --> < route > < from uri = &quot;nmr:Recipes&quot; /> < to uri = &quot;file:/home/recipes/in&quot; /> </ route > </ camelContext > </ beans >
  • 39.
  • 40.
    ServiceMix JBI Supportfor JBI 1.0 Installable in Karaf as a feature JBI 1.0 API JBI Deployment and packaging JBI Management MBeans Improvements over ServiceMix 3.x New cluster engine implementation OSGi packaging
  • 41.
    Overview ServiceMix 3to ServiceMix 4 ServiceMix 4 from the bottom up Apache Felix Karaf Apache ServiceMix NMR Apache ServiceMix JBI Wrap it up
  • 42.
    Wrap it upServiceMix 4 OSGi container with support for JBI 1.0 Option 1: Use the full package Ideal when migrating existing JBI applications Option 2: Build your own container Start with Karaf and turn it into an - integration server with Camel and CXF - OSGi app server with web console and blueprint - web application server with ActiveMQ for JMS - …
  • 43.
    References Interested? Wantto get involved? Apache Felix Karaf http://felix.apache.org/site/apache-felix-karaf.html [email_address] Apache ServiceMix http://servicemix.apache.org [email_address]
  • 44.
  • 45.
    Session Evaluation Pleasecomplete a session evaluation and turn it into any conference staff member or at the registration desk. Thank you.