gert vanthienen presentation
DESCRIPTION
TRANSCRIPT
![Page 1: Gert Vanthienen Presentation](https://reader033.vdocument.in/reader033/viewer/2022061217/54b408964a7959f7128b456f/html5/thumbnails/1.jpg)
ServiceMix 4Make the container match the project
Gert Vanthienen
r&d engineer
anova r&d bvba
![Page 2: Gert Vanthienen Presentation](https://reader033.vdocument.in/reader033/viewer/2022061217/54b408964a7959f7128b456f/html5/thumbnails/2.jpg)
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
![Page 3: Gert Vanthienen Presentation](https://reader033.vdocument.in/reader033/viewer/2022061217/54b408964a7959f7128b456f/html5/thumbnails/3.jpg)
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
![Page 4: Gert Vanthienen Presentation](https://reader033.vdocument.in/reader033/viewer/2022061217/54b408964a7959f7128b456f/html5/thumbnails/4.jpg)
Overview
ServiceMix 3 to ServiceMix 4
ServiceMix 4 from the bottom up
• Apache Felix Karaf
• Apache ServiceMix NMR
• Apache ServiceMix JBI
• Wrap it up
![Page 5: Gert Vanthienen Presentation](https://reader033.vdocument.in/reader033/viewer/2022061217/54b408964a7959f7128b456f/html5/thumbnails/5.jpg)
Overview
ServiceMix 3 to ServiceMix 4
ServiceMix 4 from the bottom up
• Apache Felix Karaf
• Apache ServiceMix NMR
• Apache ServiceMix JBI
• Wrap it up
![Page 6: Gert Vanthienen Presentation](https://reader033.vdocument.in/reader033/viewer/2022061217/54b408964a7959f7128b456f/html5/thumbnails/6.jpg)
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
![Page 7: Gert Vanthienen Presentation](https://reader033.vdocument.in/reader033/viewer/2022061217/54b408964a7959f7128b456f/html5/thumbnails/7.jpg)
![Page 8: Gert Vanthienen Presentation](https://reader033.vdocument.in/reader033/viewer/2022061217/54b408964a7959f7128b456f/html5/thumbnails/8.jpg)
![Page 9: Gert Vanthienen Presentation](https://reader033.vdocument.in/reader033/viewer/2022061217/54b408964a7959f7128b456f/html5/thumbnails/9.jpg)
Overview
ServiceMix 3 to ServiceMix 4
ServiceMix 4 from the bottom up
• Apache Felix Karaf
• Apache ServiceMix NMR
• Apache ServiceMix JBI
• Wrap it up
![Page 10: Gert Vanthienen Presentation](https://reader033.vdocument.in/reader033/viewer/2022061217/54b408964a7959f7128b456f/html5/thumbnails/10.jpg)
![Page 11: Gert Vanthienen Presentation](https://reader033.vdocument.in/reader033/viewer/2022061217/54b408964a7959f7128b456f/html5/thumbnails/11.jpg)
Apache Felix Karaf
Introducing Karaf
How-to build a Camel container?
• Command shell
• Feature descriptors
• Hot-deployment
• A few more Karaf features
![Page 12: Gert Vanthienen Presentation](https://reader033.vdocument.in/reader033/viewer/2022061217/54b408964a7959f7128b456f/html5/thumbnails/12.jpg)
Apache Felix Karaf
Introducing Karaf
How-to build a Camel Container?
• Command shell
• Feature descriptors
• Hot-deployment
• A few more Karaf features
![Page 13: Gert Vanthienen Presentation](https://reader033.vdocument.in/reader033/viewer/2022061217/54b408964a7959f7128b456f/html5/thumbnails/13.jpg)
Introducing Karaf
A flexible OSGi-based server runtime
Choice of OSGi runtime:
• Apache Felix
• Eclipse Equinox
Manage the container using:
• command shell
• web console
![Page 14: Gert Vanthienen Presentation](https://reader033.vdocument.in/reader033/viewer/2022061217/54b408964a7959f7128b456f/html5/thumbnails/14.jpg)
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
![Page 15: Gert Vanthienen Presentation](https://reader033.vdocument.in/reader033/viewer/2022061217/54b408964a7959f7128b456f/html5/thumbnails/15.jpg)
Apache Felix Karaf
Introducing Karaf
Create Camel Container
• Command shell
• Feature descriptors
• Hot-deployment
• A few more Karaf features
![Page 16: Gert Vanthienen Presentation](https://reader033.vdocument.in/reader033/viewer/2022061217/54b408964a7959f7128b456f/html5/thumbnails/16.jpg)
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
![Page 17: Gert Vanthienen Presentation](https://reader033.vdocument.in/reader033/viewer/2022061217/54b408964a7959f7128b456f/html5/thumbnails/17.jpg)
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
![Page 18: Gert Vanthienen Presentation](https://reader033.vdocument.in/reader033/viewer/2022061217/54b408964a7959f7128b456f/html5/thumbnails/18.jpg)
Karaf: Feature descriptors
Default Karaf provisioning mechanism
XML descriptor for installing software
• List of bundles to install
• Configuration information
• Dependencies between features
![Page 19: Gert Vanthienen Presentation](https://reader033.vdocument.in/reader033/viewer/2022061217/54b408964a7959f7128b456f/html5/thumbnails/19.jpg)
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>
![Page 20: Gert Vanthienen Presentation](https://reader033.vdocument.in/reader033/viewer/2022061217/54b408964a7959f7128b456f/html5/thumbnails/20.jpg)
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
![Page 21: Gert Vanthienen Presentation](https://reader033.vdocument.in/reader033/viewer/2022061217/54b408964a7959f7128b456f/html5/thumbnails/21.jpg)
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
![Page 22: Gert Vanthienen Presentation](https://reader033.vdocument.in/reader033/viewer/2022061217/54b408964a7959f7128b456f/html5/thumbnails/22.jpg)
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
![Page 23: Gert Vanthienen Presentation](https://reader033.vdocument.in/reader033/viewer/2022061217/54b408964a7959f7128b456f/html5/thumbnails/23.jpg)
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
![Page 24: Gert Vanthienen Presentation](https://reader033.vdocument.in/reader033/viewer/2022061217/54b408964a7959f7128b456f/html5/thumbnails/24.jpg)
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>
![Page 25: Gert Vanthienen Presentation](https://reader033.vdocument.in/reader033/viewer/2022061217/54b408964a7959f7128b456f/html5/thumbnails/25.jpg)
Apache Felix Karaf
Introducing Karaf
How-to build a Camel container?
• Command shell
• Feature descriptors
• Hot-deployment
• A few more Karaf features
![Page 26: Gert Vanthienen Presentation](https://reader033.vdocument.in/reader033/viewer/2022061217/54b408964a7959f7128b456f/html5/thumbnails/26.jpg)
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
![Page 27: Gert Vanthienen Presentation](https://reader033.vdocument.in/reader033/viewer/2022061217/54b408964a7959f7128b456f/html5/thumbnails/27.jpg)
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
![Page 28: Gert Vanthienen Presentation](https://reader033.vdocument.in/reader033/viewer/2022061217/54b408964a7959f7128b456f/html5/thumbnails/28.jpg)
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
![Page 29: Gert Vanthienen Presentation](https://reader033.vdocument.in/reader033/viewer/2022061217/54b408964a7959f7128b456f/html5/thumbnails/29.jpg)
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
![Page 30: Gert Vanthienen Presentation](https://reader033.vdocument.in/reader033/viewer/2022061217/54b408964a7959f7128b456f/html5/thumbnails/30.jpg)
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>
![Page 31: Gert Vanthienen Presentation](https://reader033.vdocument.in/reader033/viewer/2022061217/54b408964a7959f7128b456f/html5/thumbnails/31.jpg)
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)
![Page 32: Gert Vanthienen Presentation](https://reader033.vdocument.in/reader033/viewer/2022061217/54b408964a7959f7128b456f/html5/thumbnails/32.jpg)
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
![Page 33: Gert Vanthienen Presentation](https://reader033.vdocument.in/reader033/viewer/2022061217/54b408964a7959f7128b456f/html5/thumbnails/33.jpg)
Karaf: Web Console
![Page 34: Gert Vanthienen Presentation](https://reader033.vdocument.in/reader033/viewer/2022061217/54b408964a7959f7128b456f/html5/thumbnails/34.jpg)
Karaf: Web Console
![Page 35: Gert Vanthienen Presentation](https://reader033.vdocument.in/reader033/viewer/2022061217/54b408964a7959f7128b456f/html5/thumbnails/35.jpg)
![Page 36: Gert Vanthienen Presentation](https://reader033.vdocument.in/reader033/viewer/2022061217/54b408964a7959f7128b456f/html5/thumbnails/36.jpg)
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
![Page 37: Gert Vanthienen Presentation](https://reader033.vdocument.in/reader033/viewer/2022061217/54b408964a7959f7128b456f/html5/thumbnails/37.jpg)
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
![Page 38: Gert Vanthienen Presentation](https://reader033.vdocument.in/reader033/viewer/2022061217/54b408964a7959f7128b456f/html5/thumbnails/38.jpg)
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>
![Page 39: Gert Vanthienen Presentation](https://reader033.vdocument.in/reader033/viewer/2022061217/54b408964a7959f7128b456f/html5/thumbnails/39.jpg)
![Page 40: Gert Vanthienen Presentation](https://reader033.vdocument.in/reader033/viewer/2022061217/54b408964a7959f7128b456f/html5/thumbnails/40.jpg)
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
![Page 41: Gert Vanthienen Presentation](https://reader033.vdocument.in/reader033/viewer/2022061217/54b408964a7959f7128b456f/html5/thumbnails/41.jpg)
Overview
ServiceMix 3 to ServiceMix 4
ServiceMix 4 from the bottom up
• Apache Felix Karaf
• Apache ServiceMix NMR
• Apache ServiceMix JBI
• Wrap it up
![Page 42: Gert Vanthienen Presentation](https://reader033.vdocument.in/reader033/viewer/2022061217/54b408964a7959f7128b456f/html5/thumbnails/42.jpg)
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
- …
![Page 43: Gert Vanthienen Presentation](https://reader033.vdocument.in/reader033/viewer/2022061217/54b408964a7959f7128b456f/html5/thumbnails/43.jpg)
References
Interested? Want to get involved?
• Apache Felix Karaf http://felix.apache.org/site/apache-felix-karaf.html
• Apache ServiceMix http://servicemix.apache.org
![Page 44: Gert Vanthienen Presentation](https://reader033.vdocument.in/reader033/viewer/2022061217/54b408964a7959f7128b456f/html5/thumbnails/44.jpg)
Questions
![Page 45: Gert Vanthienen Presentation](https://reader033.vdocument.in/reader033/viewer/2022061217/54b408964a7959f7128b456f/html5/thumbnails/45.jpg)
Session Evaluation
Please complete a session evaluation and
turn it into any conference staff member or
at the registration desk. Thank you.