This document discusses the integration of Apache Servicemix and CXF. It provides an overview of JBI (Java Business Integration), components in JBI including binding components and service engines. It also discusses message exchange patterns, endpoints, and normalized message routing in JBI. Finally, it provides examples of WSDL definitions and Java interfaces used with JBI.
5. What is JBI?
JBI defines an architecture that allows the construction of integration systems
from plug-in components, that interoperate through the method of mediated
message exchange. (JBI 1.0 spec, JSR 208)
Keywords: plugin, MEPS, NMR
9. JBI 1.0: WSDL messaging model
Abstract model
Concrete model
Service providers
Service consumers
10. JBI 1.0: WSDL messaging model
Message type
Normal
Faults
Operation
Qualified name
Message Exchange Pattern
Message types
Interface
Qualified name
Operations
Extended interfaces
11. JBI 1.0: WSDL messaging model
Binding type
Endpoint
Endpoint name
Binding type
Service
Qualified name
Interface name
Endpoints
14. Java interface
@WebService(targetNamespace = quot;http://servicemix.apache.org/samples/wsdl-firstquot;, name = quot;Personquot;)
public interface Person {
@ResponseWrapper(localName = quot;GetPersonResponsequot;, targetNamespace = quot;http://servicemix.apache.org/samples/wsdl-
first/typesquot;, className = quot;org.apache.servicemix.samples.wsdl_first.types.GetPersonResponsequot;)
@RequestWrapper(localName = quot;GetPersonquot;, targetNamespace = quot;http://servicemix.apache.org/samples/wsdl-first/typesquot;,
className = quot;org.apache.servicemix.samples.wsdl_first.types.GetPersonquot;)
@WebMethod(operationName = quot;GetPersonquot;)
public void getPerson(
@WebParam(mode = WebParam.Mode.INOUT, name = quot;personIdquot;, targetNamespace = quot;http://servicemix.apache.org/samples/
wsdl-first/typesquot;)
javax.xml.ws.Holder<java.lang.String> personId,
@WebParam(mode = WebParam.Mode.OUT, name = quot;ssnquot;, targetNamespace = quot;http://servicemix.apache.org/samples/wsdl-
first/typesquot;)
javax.xml.ws.Holder<java.lang.String> ssn,
@WebParam(mode = WebParam.Mode.OUT, name = quot;namequot;, targetNamespace = quot;http://servicemix.apache.org/samples/wsdl-
first/typesquot;)
javax.xml.ws.Holder<java.lang.String> name
) throws UnknownPersonFault;
}
15. Component
Binding Component
To communicate using remote protocols
To normalize/denormalize messages it receives
Examples:
servicemix-file
servicemix-ftp
servicemix-cxf-bc
Service Engine
A service engine (SE) provides some type of logic inside the JBI environment and only
communicates with the NMR.
Examples:
servicemix-bean
servicemix-camel
servicemix-cxf-se
17. Normalized Message Router
The Normalized Message Router (or NMR) receives message exchanges from JBI
components and routes them to the appropriate component for processing. This
decouples the service producers from consumers and enable additional processing.
19. Message Normalization
Message normalization/denormalization is the act of converting a message from/
to a protocol-specific format into a format for the JBI environment. This
normalization is performed by BCs involves converting all messages into a
NormalizedMessage.
A Normalized Message consist of following:
The “payload”, or bare message: an XML document that conforms to an
abstract WSDL message type.
Message properties (sometime called metadata). These hold extra data
associated with the message, key-value
Attachments: Extra (generally binary) attachments to the main message
object.
20. what NMR looks like
id: ID:127.0.0.1-11761bd912f-8:0
status: Active
role: provider
service: {http://apache.org/cxf/calculator}CalculatorService
endpoint: CalculatorPort
operation: {http://apache.org/cxf/calculator}add
in: <?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?><message
xmlns=quot;http://java.sun.com/xml/ns/jbi/wsdl-11-wrapperquot;> <part> <add
xmlns=quot;http://apache.org/cxf/calculator/typesquot;> <arg0>1</arg0>
<arg1>2</arg1> </add> </part></message>
21. Delivery Channel
A Delivery Channel is a bidirectional asynchronous communication pipes between a
component and the NMR.
A service consumer uses its delivery channel to initiate a service invocation, while
the provider uses its delivery channel to receive such invocations.
Each component is provided with a single delivery channel, so the same channel is
used for both inbound and outbound communications.
22. Message Exchange Pattern
In-Only: consumer issues a request to provider with no error (fault) path provided
Robust In-Only: consumer issues a request to provider. Provider may respond with a
fault if it fails to process request.
In-Out: consumer issues a request to provider, with expectation of response. Provider
may respond with a fault if it fails to process request.
In-Optional-Out: consumer issues a request to provider, which may result in a
response. Consumer and provider both have the option of generating a fault in
response to a message received during the interaction
27. Endpoints
JBI uses the same concept of endpoints as defined in WSDL 2.0.
Endpoints refers to a particular address, accessible by a particular protocol, used to
access a particular service.
Endpoints have two distinct types:
External
External endpoints are endpoints outside the JBI environment. They are endpoints
exposed by binding component acting as service consumers to expose an internal
endpoint for the use of external service consumers
Internal
Internal endpoints are exposed by service providers inside the JBI environment. They
are accessed using the NMR APIs.
28. Addressing
In JBI, endpoints are referred to (or addressed) in three distinct ways:
● Implicitly: the NMR selects the endpoint based on the service type required.
● Explicitly: a consumer chooses the endpoint based on its own logic and
configuration.
● Dynamically: an endpoint reference (EPR) is used within a message exchange to
provide a “ call-back” address that the service provider should use to send further
message exchanges. EPRs are xml fragment created and resolved by JBI
components.
30. JBI Package
JBI defines a standard packaging for installing new components and deploying
artifacts onto these components that can function as quot;containersquot;.All these artifacts
contain a JBI descriptor in the META-INF directory called jbi.xml.
There are four types of artifacts, all packaged as zip or jar files:
Components installers contain the libraries and resources needed to run the component.
Components can references Shared Libraries.
Shared Libraries are collection of jars that can be shared by several components
Service Units are artifacts meant to be deployed to a specific component. Aside from the
JBI descriptor, the service unit packaging is specific to a component and can take various
forms: a single XSLT style sheet, a BPEL process, or some java classes ...
Service assemblies are collections of Service Units. Service units can not be deployed
directly and must be packaged in a service assembly which contains the service units and
associated metadata.
33. service assembly
<?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?>
<jbi xmlns=quot;http://java.sun.com/xml/ns/jbiquot; version=quot;1.0quot;>
<service-assembly>
<identification>
<name>wsdl-first-cxf-sa</name>
<description>ServiceMix :: Samples :: WSDL first :: SA</description>
</identification>
<service-unit>
<identification>
<name>wsdl-first-cxfse-su</name>
<description>ServiceMix is an open source ESB based on the Java Business
Integration framework - JSR-208</description>
</identification>
<target>
<artifacts-zip>wsdl-first-cxfse-su-3.3.zip</artifacts-zip>
<component-name>servicemix-cxf-se</component-name>
</target>
</service-unit>
<service-unit>
<identification>
<name>wsdl-first-cxfbc-su</name>
<description>ServiceMix is an open source ESB based on the Java Business
Integration framework - JSR-208</description>
</identification>
<target>
<artifacts-zip>wsdl-first-cxfbc-su-3.3.zip</artifacts-zip>
<component-name>servicemix-cxf-bc</component-name>
</target>
</service-unit>
</service-assembly>
</jbi>
34. Package Install & Deploy
For the shared library & component, it is called installation
For the service assembly, it is called deployment
In general, Container Developer (like us) write the component, Application
Developer write the serivce unit and service assembly.
35. ClassLoader
There are several classloaders involved in ServiceMix:
the container class loader.
shared library class loader: the parent is the container class loader.
component class loader: parents are container class loader + any referenced SL
class loader.
service unit class loader: parent is the component class loader.
Two kinds of classloader algorithm.
parent-first. (by default)
self-first.
36. CXF-BC & CXF-SE
why we integrate cxf into servicemix?
what's the key components for this integration?
37. Cxf BC
cxf bc consumer
cxf bc provider
http support
https support
jms support
ws-* support
41. typical scenario
external client<==>cxf bc cosumer<==NMR==>cxf se endpoint
or
client proxy in cxf se<==NMR==>cxf bc provider<===>external server
42. JBI binding & JBI transport
src code is in cxf code base
JBI binding is responsible for the
Marshalling/Unmarshalling
JBI transport is reponsible for receiving and
sending message using JBI api
46. Servicemix 4.0 : Goal
Enterprise OSGi Container
Lightweight
ESB and SOA container
Ease of use
47. SMX4.0: Ease of Use
No more components.
Deployment / Classloader is delegated to OSGi.
Bundles as the packaging and extension mechanism.
Leverage OSGi architecture.
Leverage spring-osgi (optionally)
Endpoints as first-class citizens
Endpoint are activated when registered in the OSGi registry.
Channel is now on the Endpoint.
Endpoints use push delivery rather than pulling the channel.