gert vanthienen presentation
DESCRIPTION
TRANSCRIPT
ServiceMix 4Make the container match the project
Gert Vanthienen
r&d engineer
anova r&d bvba
Who am I?
Gert Vanthienen ([email protected])
• 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 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
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="1.0" encoding="UTF-8"?><features name="karaf-1.1.0-SNAPSHOT">
<feature name="http" version="1.1.0-SNAPSHOT"> <config name="org.ops4j.pax.web"> org.osgi.service.http.port=8181 </config> <!-- snip --> <bundle>mvn:org.ops4j.pax.web/pax-web-bundle/0.6.0</bundle> </feature>
<feature name="webconsole" version="1.1.0-SNAPSHOT"> <feature version="1.1.0-SNAPSHOT">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/featureskaraf@root> features:install camel-o
camel-ognl camel-osgikaraf@root> features:install camel-osgikaraf@root> features:install camel-ftp
Karaf: Create a Camel container
Deploy the route in a Spring XML
<?xml version="1.0"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" 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">
<camelContext xmlns="http://camel.apache.org/schema/spring"> <route> <from uri="ftp://[email protected]/recipes?password=secret"/> <to uri="file:/home/recipes/in"/> </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="1.0"?><blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
<service interface="org.tssjs.smx4.Restaurant"> <bean class="org.tssjs.smx4.impl.RestaurantImpl"> <property name="location" value="Prague"/> <property name="kitchen" ref="kitchenRef"/> </bean> </service> <reference id="kitchenRef" interface="org.tssjs.smx4.Kitchen"/>
</blueprint>
Karaf: Blueprint Services
• Install bundles and check status
karaf@resto> osgi:install -s mvn:org.tssjs.smx4/restaurant/1.0Bundle ID: 30karaf@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: 31karaf@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="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="...">
<import resource= "classpath:org/apache/servicemix/camel/nmr/camel-nmr.xml" />
<camelContext xmlns="http://camel.apache.org/schema/spring"> <route> <from uri="ftp://[email protected]/recipes?password=secret"/> <to uri="nmr:Recipes"/> </route>
<!-- the second route can be in another bundle/xml file --> <route> <from uri="nmr:Recipes"/> <to uri="file:/home/recipes/in"/> </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
• Apache ServiceMix http://servicemix.apache.org
Questions
Session Evaluation
Please complete a session evaluation and
turn it into any conference staff member or
at the registration desk. Thank you.