5. JBI

Overview

What is JBI ?

A Brief Intro to JBI

A brief introduction to JBI is available in the What is JBI? document. This document is more in-depth and supplemental.

JBI is a java based standard to build integrations systems by using plug-in components which interoperates through mediated normalized message exchanges.
The message exchange model is based on the web services description language (WSDL).

The figure at the top shows a high level concept of JBI of the plug-in framework. The JBI environment provides interfaces to be used by plug-in components, while the components provides interfaces used by the JBI environment. Components do not interact with each other directly. Instead, as shown in the bottom figure, JBI acts as an intermediary to route messages between components. This separation is the key to decoupling between service providers and consumers, which is one of the goal of service oriented architectures. In addition, it provides a key point for message processing and monitoring.

JBI plugin framework

JBI decoupling

In this WSDL-based, service-oriented model, JBI plug-in components are responsible for providing and consuming services. By providing a service, a component is making available a function or functions that can be consumed by other components (or even itself). Such functions are modeled as WSDL 2.0 operations, which involve the exchange of one or more messages. A set of four WSDL-defined, basic message exchange patterns (MEPs) crisply defines the sequence of messages allowed during execution of an operation. This shared understanding, between consumer and provider components, of the message exchange pattern is the foundation of interoperability of such components in JBI.

The services provided by components (if any) are described to JBI by the component, using WSDL 1.1 or 2.0. This provides an abstract, technology-neutral model of services using XML-based message exchanges. WSDL also provides a mechanism for declaring additional service metadata of interest to service consumers and JBI itself. Components can query JBI for the for the WSDL describing available services.

JBI Architecture

This picture describes the architecture of the JBI system.

  • The JBI environment provides deployment, control & monitoring features through JMX based administration tools
  • The Normalized Message Router or NMR, which provides the mediated message exchange infrastructure
  • Components (in white rectangles)

Components are divided in two categories:

  • Service Engines (on top) provides business logic and transformation services and also consumes such services.
  • Binding Components provide connectivity to services external to the JBI environment.
    Service engines and binding components can function as service providers, consumers, or both. Note that the distinction between SEs and BCs is purely pragmatic, but the separation of business logic from communications logic reduces complexity and increases flexibility.
JBI Architecture

The JBI environment, in addition to the messaging system, defines a management structure based on JMX which provides standard mechanisms for:

  • Installing components
  • Managing a component's life cycle (start / stop)
  • Deploying service artifacts to components
    JBI components often function as a type of container to which artifacts can be deployed to add new service or provider logic. For example, a service engine that provides XSLT-based transformation services would have XSLT style sheets deployed to it, in order to add new transformation operations. This process of adding such component-specific artifacts to an installed component is called deployment, to distinguish it from component installation. Such an artifact is called a service unit, while collection of deployment artifacts and associated metadata is called a service assembly.

The core message exchange concept implements WSDL messaging. Service requests are generated by consumer components, routed by the NMR, and delivered to a provider component. For example, the BPEL SE may generate a request, which happens to be provided by the external service provider connected to the WS-I BC. The NMR will route the request to the WS-I binding. The SE in this case is a service consumer, and the BC a provider.

top

WSDL messaging model

JBI models services produced and consumed by components using Web Service Description Language 1.1 or 2.0. When the terminology differs between the two version, the 2.0 one is used. This is mainly the case for the interface and endpoint terms, which are called respectively "port type" and "port" in WSDL 1.1.

WSDL provides a declarative model of message-based services on two levels:

  • The abstract model defines services without references to a particular protocol or wire encoding
  • The concrete model is bound to a particular communication protocol and communications endpoint

JBI uses the abstract service model as the main basis for component interactions. Components play one of two roles in such interactions:

  • Service provider. The component that performs the given service (either directly or as a proxy for an external provider)
  • Service consumer. The component that invokes a given service (either directly or as a proxy for an external consumer)
WSDL Messaging Model

Abstract model

JBI models services produced and consumed by components using Web Service Description Language 1.1 or 2.0. When the terminology differs between the two version, the 2.0 one is used. This is mainly the case for the interface and endpoint terms, which are called respectively "port type" and "port" in WSDL 1.1.

WSDL service description always include an abstract service model which defines:

  • Message types are defined using XML schema. These can be normal messages (for the expected use of the service) or faults (for abnormal processing conditions).
  • Operations are interactions with a service defined in terms of normal and optional faults messages between a service consumer and a service provider. An operation is defined by:
    • An operation name which is a qualified name
    • A Message Exchange Pattern (MEP) that describes the sequence, direction and cardinality of messages sent between the consumer and provider.
    • Message types for each message in the MEP.
  • Interfaces are collections of related operations. Note that this term is unrelated to the Java Language interface definition. An interface is defined by:
    • An interface name: a qualified name identifying the service type globally
    • A set of extended interfaces. This is the same concept as in the Java Language. This means a service type may be composed of other service types.

JBI uses the abstract service model as the main basis for component interactions. Components play one of two roles in such interactions:

  • Service provider. The component that performs the given service (either directly or as a proxy for an external provider)
  • Service consumer. The component that invokes a given service (either directly or as a proxy for an external consumer)

Concrete model

Concrete service descriptions in WSDL build upon the abstract service model, supplying information needed to "map" the abstract definition to a particular communications protocol and communications endpoint. JBI bases its component interaction model primarily on the abstract service model, thus giving it the desirable property of being communications protocol neutral. However, to be consistent with the WSDL service model, component interactions need to be defined using WSDL's concrete service model. In JBI this is a very simple model, using the abstract model "as is" wherever possible, thus creating a simple processing model for interacting components.

The concrete service model defines the following items:

  • Binding types. A binding type identifies the type of protocol to which the service is being "bound".
  • Endpoints. An endpoint designates the communications endpoint information needed by a service consumer to interact with a service provider, using a particular protocol. In JBI endpoints are pro forma; the only protocol used internally is the standard Java-based JBI messaging contracts, which do not involve the use of normal communications protocols at all. An endpoint definition includes the following items that are of interest to JBI:
    • Endpoint name. This is a simple name, used to designate the endpoint within its service.
    • Binding type. This associates a binding type with an endpoint.
  • Service. A service is a collection of endpoints that offer access to the same service. A service "implements" a particular service type (interface). A service has the following items:
    • Service name. A qualified name used to indicate the particular service implementation.
    • Service type name. The name of the interface implemented by the service.
    • Endpoints. The service "contains" one or more endpoints, which are the individual endpoints providing access to the concrete service.
Mapping WSDL to a SU

The image to the right displays an example of how these items are mapped from a ServiceMix SU project into WSDL. This example applies to both the servicemix-http and the servicemix-jsr181 components that come with ServiceMix.

Note that normally an endpoint is identified by the combination of its service name and its endpoint name. This combination is referred to as the service endpoint.

top

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.

Consumers and providers

JBI components (Service Engines and Binding Components) can act as a service consumer, a service provider or both. The diagram to the right outlines this using the example of a ServiceMix HTTP Consumer BC and a ServiceMix HTTP Provider BC. Notice where requests are initiated and the direction of the arrows to denote the flow from the initiator.

The provider makes a WSDL-described service available through an endpoint. This service implements a WSDL interface, which is a collection of operations.
The consumer can invoke the service by creating a message exchange that invoke a particular operation.
Consumers and providers only share the abstract service definition and are thus decoupled, as the consumer does not know the protocol and location of the invoked service.
Several services can implement the same WSDL interface so a consumer looking providers of an interface may find more than one endpoint.

Consumers vs. Providers

Normalized message

JBI uses the concept of a normalized message for interactions between consumers and providers.
A normalized message consists of three parts:

  • A payload, which is an xml document that conforms to a WSDL message type without any protocol or encoding
  • Properties (or metadata) holds extra data associated with the message (security, transactions ...)
  • Attachments are arbitrary (non-xml) data that contain a data handler to manipulate them
JBI Normalized Message

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.

Endpoint activation

Endpoint activation is the process by which a service provider tells the NMR that it provides services, making them known to the NMR so that it can route service invocations to that service.

The activation is split in two steps"

  • Declaring a service endpoint (service QName + endpoint name)
  • Providing metadata: the component has to provide a WSDL description of the activate endpoint
    The WSDL description will be used by the NMR to know which interfaces and operations are implemented by the activated endpoint.

Service invocation and MEP

Service invocation refers to an instance of an end-to-end interaction between a service consumer and a service provider.

Four patterns are supported by JBI:

  • 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.

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 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 endpoints are exposed by service providers inside the JBI environment. They are accessed using the NMR APIs.

Binding components serve to map between internal and external endpoints. For example, an internal endpoint exposed outside the JBI environment by a binding component is mapped by the BC to an external provider endpoint for the use of external consumers.

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.

Invocation example

This sequence diagram shows a InOut service invocation between a consumer and a provider.

Invocation example

  1. The consumer creates an InOut message exchange, populates the "in" message (the request) and send it to the NMR
  2. The provider component polls the delivery channel for an exchange
  3. It processes the request, populates the "out" message and send it back to the NMR
  4. The consumer polls the delivery channel for the response
  5. It processes the response and mark the exchange as "done"
  6. The provider receives the "done" status from the delivery channel

This example is an asynchronous invocation, but JBI also handles synchronous calls. In such a case, the consumer call to send would be a sendSync and would block the thread until the response is received. On the provider side, if the provider wish to synchronously deliver the response, the call to send (#3) would block until the consumer acks the response.

When an exchange involves a binding component, either as a consumer or a provider, the same diagram applies. The difference is that the exchange creation would be triggered by an external request (a JMS message, or an HTTP request) before step #1 and send the response after step #4. If the provider is a binding component which proxies a remote service, it would invoke the service between the steps #2 and #3.

People may wonder why there is a need for a "done" status... In JBI, all exchanges are terminated by either a "done" or an "error" status. Errors are different from faults which are parts of the normal exchange processing. So, the done status is very useful to implement reliable message, transactions or passing streams inside the exchange.
Let's take the example a file binding component, which would poll for files, send the content as an InOnly request, and delete them afterwards. For performance reasons, it will send an opened stream on the file, but it has to close the stream and delete the file once processed. If the consumer is asynchronous (which is better because it saves threads), it needs a way to know when the file has to be deleted, hence the need for the "done" status.

top

JBI packaging

JBI defines a standard packaging for installing new components and deploying artifacts onto these components that can function as "containers".
All these artifacts contain a JBI descriptor in the META-INF directory called jbi.xml.

JBI Packaging

We have already discussed some of these artifacts, but let's dive in them a bit more. 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.

A service assembly is thus a zip of zips. It can be compared to an EAR in the J2EE world. To ease the pain of packaging the JBI artifacts, ServiceMix provides a powerful maven based tooling which can package all the JBI artifacts and generate their JBI descriptors automatically. To ease the development more, we provide maven archetypes for JBI components and service units: archetypes are templates that can generate a project in one command line (see Notes on Creating JBI Component using maven2).

top

Other materials

top