Apache ServiceMix 4.2.0
Apache ServiceMix 4.2.0
1/80
This work is licensed under the Creative Commons Attribution 2.0 Belgium License. To view a copy of this license, visit http://creativecommons.org/licenses/by/2.0/be/ or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.
Planning
Overview and architecture Getting started Camel Normalized Message Router Java Business Integration
3/80
Planning
Overview and architecture Getting started Camel Normalized Message Router Java Business Integration
4/80
ServiceMix 4
Open-source ESB
5/80
ServiceMix 4 consists of
Apache Felix Karaf Apache Camel Apache ActiveMQ NMR implementation JBI implementation
6/80
7/80
Planning
Overview and architecture Getting started Camel Normalized Message Router Java Business Integration
8/80
Getting started
9/80
Getting started
Download
.tar.gz for Linux, Unix, Solaris and MacOS .zip for Windows
10/80
Installation
Requirements
100 MB free disk space JDK 1.5 or higher unzip the archive to the local disk
Installation
11/80
interactive
12/80
in the background
bin/start script starts ServiceMix bin/stop scripts stops ServiceMix access the console
13/80
as a service
uses Tanuki Java Software Wrapper start ServiceMix interactively in the console
14/80
15/80
Planning
Overview and architecture Getting started Camel Normalized Message Router Java Business Integration
16/80
Camel
17/80
Camel
18/80
Introduction
open-source mediation and routing based on Enterprise Integration Patterns routes are defined in
19/80
karaf@root> features:list [installed ] [2.2.0 [installed ] [2.2.0 [installed ] [2.2.0 [uninstalled] [2.2.0 [uninstalled] [2.2.0 [uninstalled] [2.2.0
20/80
Plain Spring XML DSL deployment Spring XML DSL in a bundle Java/Scala DSL in a bundle
21/80
22/80
Spring XML file in META-INF/spring in the Spring XML file itself in Java/Scala DSL RouteBuilders
23/80
24/80
easy to use feature-rich lots of components available add other technology when necessary
ActiveMQ for reliable, async messaging CXF for web services support NMR JBI
25/80
Planning
Overview and architecture Getting started Camel Normalized Message Router Java Business Integration
26/80
NMR
27/80
NMR
28/80
Introduction
Used for
foundation for JBI support Camel NMR messaging CXF NMR messaging
Messaging API with OSGi-based implementation Ensure ServiceMix' independence of different messaging technologies
29/80
Introduction
Other features
ExchangeListener EndpointListener
30/80
NMR API
Exchange
31/80
NMR API
Message
body support for both XML and Object payloads headers attachments
32/80
NMR API
33/80
NMR API
Listener interfaces
ExchangeListener EndpointListener register Listener interfaces in OSGi Service Registry NMR will invoke methods on all registered instances
34/80
NMR API
Example: ExchangeListener
private class MyExchangeListener implements ExchangeListener { public void exchangeDelivered(Exchange exchange) { } public void exchangeFailed(Exchange exchange) { } public void exchangeSent(Exchange exchange) { } }
35/80
NMR API
Example: EndpointListener
public class MyEndpointListener implements EndpointListener { public void endpointRegistered(InternalEndpoint endpoint) { } public void endpointUnregistered(InternalEndpoint endpoint) { } }
36/80
NMR API
37/80
Camel Component
38/80
39/80
for linking Camel routes across bundles (with the Camel NMR component) for linking CXF endpoints across bundles (with the CXF NMR transport) if you require support for pluggable ExchangeListener/EndpointListener (e.g. auditing or BAM)
40/80
Exercise
Add import to Spring XML Add NMR endpoints to connect two routes Log exchange IDs and properties Ensure that the listener can be dynamically (de)activated by stopping/starting the bundle
41/80
Planning
Overview and architecture Getting started Camel Normalized Message Router Java Business Integration
42/80
JBI
Introduction JBI 1.0 in depth Packaging options ServiceMix JBI Components When to use JBI? Exercise
43/80
JBI
44/80
Introduction
Pluggable architecture for integration systems Components interoperate through mediated message exchange
45/80
Introduction
version 3.x is a pure JBI container version 4.x is OSGi-based implementation version 2010.01 is latest compatible with both versions
46/80
SPI for JBI Component developers Messaging API Mechanism for exchanges to flow between components Standard for packaging components and for packaging the services deployed on them Administration and management hooks to allow for standard tools
47/80
2 kinds of components
Service Engine (SE) Allow implementing business logic or services on the ESB e.g. servicemix-drools or servicemix-bean Binding Components Provide connectivity to external services (transport, normalization, ...) e.g. servicemix-ftp or servicemix-http
48/80
Messaging API
MessageExchange contains
in, out and fault NormalizedMessage exchange properties metadata for routing
exchange id exchange pattern error service, endpoint, operation, interface role and status
49/80
Messaging API
NormalizedMessage contains
50/80
51/80
Endpoints
Internal endpoints
exposed within the JBI environment examples: file sender endpoint bean endpoint endpoints 'outside' of JBI environment examples: file poller endpoint jms consumer endpoint
52/80
External endpoints
MessageExchange routing
static with service (and endpoint) name static with interface name dynamic with endpoint reference (EPR)
53/80
MEPs
InOnly : in message InOut : in message and out (or fault) message RobustInOnly : in message, optionally fault message on in InOptionalOut : in message, optionally out (or fault), optionally fault message on out
54/80
55/80
56/80
Packaging options
57/80
Packaging options
58/80
Packaging options
59/80
Packaging options
JBI Packaging
60/80
Packaging options
add all endpoints in a single Spring XML add o.a.s.common.osgi.EndpointExporter to register JBI endpoints add XML file to META-INF/spring folder
61/80
Packaging options
62/80
Binding Components
servicemix-cxf-bc servicemix-file servicemix-ftp servicemix-http servicemix-jms servicemix-mail servicemix-smpp servicemix-snmp servicemix-truezip servicemix-vfs servicemix-xmpp
63/80
servicemix-file
namespace uri http://servicemix.apache.org/file/1.0 <file:poller/> for reading files <file:sender/> for writing files
64/80
<beans xmlns:file="http://servicemix.apache.org/file/1.0" xmlns:course="urn:be:anova:course:servicemix:jbi"> <file:poller service="course:poller" endpoint="poller" targetService="course:sender" file="file:orders/input" /> <file:sender service="course:sender" endpoint="sender" directory="file:orders/output"/> </beans>
2010 anova r&d bvba
65/80
Sidetrack: Marshalers
convert transport specific data format into XML (and back again) default implementations available for XML, implement your own for other data formats
66/80
Sidetrack: Marshalers
String getOutputName(MessageExchange, NormalizedMessage) { //TODO: determine file name } void writeMessage(MessageExchange, NormalizedMessage, OutputStream, String) { //TODO: write NormalizedMessage content to OutputStream as CSV } void readMessage(MessageExchange, NormalizedMessage, InputStream, String) { //TODO: read CSV from InputStream and convert to // NormalizedMessage content (Source) }
2010 anova r&d bvba
67/80
servicemix-jms
jms:consumer, jms:soap-consumer and jms:jcaconsumer for receiving JMS messages jms:provider and jms:soap-provider for sending JMS messages
68/80
69/80
Service Engines
servicemix-bean servicemix-camel servicemix-cxf-se servicemix-drools servicemix-eip servicemix-exec servicemix-osworkflow servicemix-quartz servicemix-saxon servicemix-scripting servicemix-validation servicemix-wsn2005
70/80
servicemix-bean
<bean:endpoint /> to define POJO endpoint auto-deployed endpoints using @Endpoint annotation
71/80
}
2010 anova r&d bvba
72/80
73/80
servicemix-camel
use Camel for routing inside JBI container Spring CamelContext for deployment URI for interacting with JBI
74/80
servicemix-camel
from(jbi:...)
exposes an internal endpoint can be used as target service for other endpoints send to another JBI endpoint from within your Camel route
to(jbi:...)
75/80
76/80
77/80
When use of external standards is required To leverage existing investments in JBI To leverage third-party JBI components For building WSDL-oriented SOA applications Support for BPEL using ODE's JBI deployment
78/80
Exercise
create a Camel route to link the two file endpoints and do the XSL transformation
Define the endpoints in bridge.xml to create a HTTP to JMS bridge In the file-to-bean project
add the file endpoint display the exchange id and properties from bean endpoint
79/80
Planning
Overview and architecture Getting started Camel Normalized Message Router Java Business Integration
80/80