An Overview of JBI

Post on 06-Jan-2016

18 views 1 download

description

An Overview of JBI. May 2007. About Me. Application Architect with Daugherty Business Solutions Working on a Fraud Detection Platform NOT doing integrations right now :-( Implemented several of Hohpe’s patterns in JMS. Part 0 - The “level-set”. We all know Java, except Stacey - PowerPoint PPT Presentation

transcript

An Overview of JBI

May 2007

About Me

Application Architect with Daugherty Business Solutions

Working on a Fraud Detection Platform

NOT doing integrations right now :-(

Implemented several of Hohpe’s patterns in JMS

Part 0 - The “level-set”

We all know Java, except Stacey

We’ve played with Web services and WSDL

We know <sarcasm> and love </sarcasm> XML

May have used JMS or another messaging provider, IBM MQSeries, MSMQ etc.

A motivating example...

Consider the traditional client/server application...

Client/Server Problems

Tight coupling

Protocol independence? (TCP/IP connection-oriented protocol)

No platform independence - 32 or 64 bit, PC to Mainframe, etc.

No recovery

No failover

Enterprise “Opportunities”

Data is transported between apps

Data needs to be understood by both apps

Require a communication channel to move the information

Two endpoints must be available

Information is transported as a message

Definitions...

Service-Oriented Architecture (SOA)

A design approach (paradigm) that encapsulates application logic in a set of services that interact using a common communications protocol.

Communications protocols can be XML-based Web services, JMS, CORBA etc.

Enterprise Service Bus(ESB)

Data grid capable of spanning the Enterprise globally

Standards-based integration

Integrates with anything that supports SOAP and Web services

Highly distributed, deployed services

ESB continued...

Distributed Data transformation

Remote configuration and management

Uses XML as the lingua franca of communication

Real-time Business data

Web Service

Based on open standards

Discoverable, distributed Service

XML based interaction

Platform agnostic

Vendor neutral

Web Service RolesServices can assume different roles when involved in different integration scenarios:

Service provider

Service requestor

Intermediary

Initial sender

Ultimate receiver

WSDL (whiz-dul)WSDL 1.1 originally submitted by Ariba, IBM and Microsoft

XML document describing a Web service

Binding section “operation” attribute is the exposed service

Each operation requires a SOAP action to be defined

Document Structure

<definitions>

<types></types>

<message></message>

<portType></portType>

<binding></binding>

</definitions>

Document Sample<definitions name=”OrderingService”>

<message name=”placeOrderRequest”><part name=”custName” type=”string”/><part name=”prodNum” type=”string”/>

</message><message name=”placeOrderRequest”>

<part name=”custName” type=”string”/><part name=”prodNum” type=”string”/>

</message>

<portType name=”OrderingPort”><operation name=”placeOrder”>

<input message=”placeOrderRequest”/><output message=”placeOrderResponse”/>

</operation></portType>

<binding type=”OrderingPort” name=”OrderingBinding”><soap: binding style=”rpc” transport=”http”/><operation name=”placeOrder”/>

</binding>

<service name=”SalesOrderService”><port binding=”OrderingBinding”>

<soap:address location=”http://...”/></port>

</service></definitions>

SOAP (not the cleaner)

A W3C Spec, originally submitted by Microsoft

A protocol for exchanging XML-based messages and accessing Webservices

Allows for RPC and Document styles of communication

SOAP message consists of Envelope and Body

Sample SOAP Request

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <getProductDetails xmlns="http://warehouse.example.com/ws"> <productID>827635</productID> </getProductDetails> </soap:Body> </soap:Envelope>

Source: http://en.wikipedia.org/wiki/SOAP

Sample SOAP Response

Source: http://en.wikipedia.org/wiki/SOAP

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <getProductDetailsResponse xmlns="http://warehouse.example.com/ws"> <getProductDetailsResult> <productName>Toptimate 3-Piece Set</productName> <productID>827635</productID> <description>3-Piece luggage set. Black Polyester.</description> <price currency="NIS">96.50</price> <inStock>true</inStock> </getProductDetailsResult> </getProductDetailsResponse> </soap:Body> </soap:Envelope>

Messaging

Some form of data exchange between a provider/sender and a consumer/receiver of information through an Enterprise channel

Message...Hohpe’sA data record that the messaging system can transmit through a “Message Channel”

Consists of header information used by the messaging system that describes the data being transmitted, its origin, its destination etc. (Note: Message Routing semantics)

Message...Buschmann/Henney/Schmidt

Message queuing systems, such as IBM MQSeries or Microsoft MSMQ messages, define a user-defined body with which higher layers can implicitly transmit user data. (Infers Message Routing intelligence)

Message...Krafzig/Banke/Slama

Consists of header and a payload. The structure of the header file is usually predefined by the system and contains network routing information

So, how does JBI define a Message?

Called a Normalized Message

Consists of 3 parts:

a payload - XML document that conforms to WSDL message type

message properties/metadata (a.k.a routing information)

message attachments

What do they all agree on?

A message contains a data payload and supplemental information that allows it to be intelligently routed through some sort of message delivery channel

Basic Integration

Sending messages through a channel that may, or may not, provide transformations and/or business logic between endpoints.

So what were integrations prior

to JBI?

Integrations, silly!

Integration Patterns

Integration Components

Application(s)

Channel

Message

Endpoints

Message Router

Applications

Can be either a provider or consumer of a particular service

Acts as an Endpoint, stay tuned...more on this in a few minutes

Channel

Logical address, not physical

Agreed upon by both consumer and producer

A good example: http://www.foo.com

JMS: Topic or Queue

MessageA representation of “some” data

The payload that either consumer or producer care about

E.g. Raw bytes, formatted text (XML) etc.

Metadata describing routing information through ESB

Endpoints

Initiator or receiver of information

one end of the entire integration

Or can be a router of information to other consumers

JMS: Topics have subscribers

Message Router

Logcially routes messages based on payload, content or other metadata

Example Patterns: Message Broker, Message Dispatcher, Splitter, Filter

Message TransformationsWhen sender and receiver do not agree on the format

Converts a message from one format to another

Hohpe’s patterns: Message Translator, Content Enricher, Normalizer etc.

Ok John, get to the point!

Java Business Integrations

JBI - The What?

JSR 208, Standard Specification

Infrastructure and Component framework for integrations

JBI Components plug into the JBI Framework

JBI - What? part deux

Divided into Service Engine Components and Binding Components

Components communicate through mediated Message Exchanges

Service Engine (SE)Components

Plug-in components provide business logic, transformational services etc.

Some SE's can contain other SE's, “container of containers”

ServiceMix provides SE's for JMS, EJB, Drools, HTTP and many many more

Binding (BC) Components

Provide connectivity to components external to the JBI environment

Send and receive messages for some particular protocol and transports

Provide a sort of adapter for messages and the transport and protocol

JBI ManagementManagement Structure based on JMX

Standardizes:

Installation

Managing component lifecycle

Deploying services to components

Components can act as a container for other components

JBI RolesSimilar to JEE, based on roles for development and deployment

Integration Architect – designs the overall approach to solving integration problems

Integration Technologist – identifies particular services needed for solving integration problems

Roles continued...

System Administrator – installs, configures and monitors the JBI environment

JBI Component Developer – provides Java components that conform to the JBI-spec contracts

JBI Architecture

WSDL-based Messaging Model

Declarative (XML) service model

Supports plug-in components

Management configuration through JMX

WSDL Messaging Model

Produces or Consumes services using WSDL 1.1 or WSDL 2.0 specifications

Abstract Model

Concrete Model

Abstract ModelMessage Types defined in XML schema

Operations defined with a name and a Message Exchange Pattern (MEP) and a type

Interfaces - collections of related operations (not the same as a Java interface)

Communication protocol neutral

Concrete ModelBuild upon the Abstract Service Model

Maps abstract definition to communication protocol and communication endpoint

Binding type - communication protocol

Endpoints - designates endpoint information

Service - name, type and endpoint of service

Normalized Message Router

(NMR)Receives Message Exchanges from JBI components

Routes to appropriate handling component

Decouples Producers from Consumers enabling different processing

Normalized Message

Defined earlier

JBI’s “version” of a plain Message

Consists of 3 parts:

Message metadata for routing

Payload

Arbitrary attachments

Delivery ChannelBidirectional communications pipe

Asynchronous

Consumers use channel to initiate service invocation

Producers use channel to receive invocations

Same channel is used for both inbound and outgoing message exchanges

Endpoint Activation

When a Service notifies the NMR that it provides a particular service

Activation is split into 2 steps:

Declaring the Service Endpoint

Provides metadata - a WSDL description of the active endpoint

Message Exchange Patterns (MEP)

describes sequence, direction and cardinality of messages sent between consumer and provider

In-Only - fire and forget

Robust-In-Only - response on fault

In-Out - obvious

In-Optional-Out

Sample In-Out MEP

InOut me = client.createInOutExchange();me.setService(new QName("urn:test", "service"));me.getInMessage().setContent(new StringSource("<hello>world</hello>"));client.sendSync(me);

if (me.getStatus() == ExchangeStatus.ERROR) { ...}

EndpointsJBI uses same definition as WSDL 2.0 Spec

“Defines the particulars of a specific endpoint at which a given service is available”

Can be either internal or external

Has name, binding and address properties

Addressed either implicitly, explicitly or dynamically

Runtime Environment

Sample Invocation

Image obtained from: http://incubator.apache.org/servicemix/5-jbi.html

JBI Components

Service Providers - fulfills the particular service request

Service Consumers - invokes a given service either directly or indirectly

Component Lifecycle

Packaging JBI Components

Defines standard packaging for new components

Components use a descriptor, jbi.xml

Packaged as .zip or .jar files

Packaging TypesComponents - contains libraries and resources to run component

Shared Libraries - collection of reusable artifacts packaged as JARs

Service Units - artifacts deployed for a specific component, XSLT style sheet, BPEL process, POJO’s etc.

Packaging Types cont...

Service Assemblies - collection of Service Units

Unit of Deployment is the Service Assembly in JBI

Metadata Configuration

jbi.xml - used by the Service Assembly for deployment configuration information

xbean.xml - used at the component level for service configuration information

Sample jbi.xml <service-assembly> <identification> <name>hello-world-sa</name> <description>Hello World Service Assembly</description> </identification> <service-unit> <identification> <name>hello-world-su</name> <description>hello-world-su</description> </identification> <target> <artifacts-zip>hello-world-su-1.0-SNAPSHOT.zip</artifacts-zip> <component-name>hello-world-se</component-name> </target> </service-unit> <service-unit> <identification> <name>hello-world-bc-su</name> <description>hello-world-bc-su</description> </identification> <target> <artifacts-zip>hello-world-bc-su-1.0-SNAPSHOT.zip</artifacts-zip> <component-name>servicemix-http</component-name> </target> </service-unit> </service-assembly>

Recommended Readings

JBI Specification, JSR 208, finalized August 17, 2005

Enterprise Service Oriented Architectures, James McGovern et al.

Enterprise Integration Patterns, Gregor Hohpe et al.

Readings continued...

Pattern-oriented Software Architectures, Frank Buschmann et al.

Enterprise SOA, Dirk Krafzig et al.

Enterprise Service Bus, David A. Chappell

Service-Oriented Architecture, Thomas Erl

Enterprise Integration Patterns

Written by Gregor Hohpe, formerly a ThoughtWorks, now Google, Employee

Patterns describe interactions for message Endpoints, Construction, Channels, Routing, Transformation and System Management

Pattern-Oriented Software

ArchitectureWritten by Frank Buschmann, Kevlin Henney and Doug Schmidt

Volume 4 in a series

Pattern language for Distributed Computing

Formalizing a pattern language for integrations as well other distributed computing concepts

Things not covered...

Distributed Component Transactions

Event-based architectures

UDDI, Service Registry and Discovery

Security (WS-basic profile)

Apache ServiceMixApache Project

Opensource ESB

JBI-compliant

Currently at version 3.1

Licensed under an Apache 2.0 license

Built on-top of ActiveMQ

Includes components for HTTP, JMS, BPEL, Rules/Drools and many more

Demo

Basic (legacy) Integration Scenario using JMS and Apache ServiceMix

Successful integrations are uninteresting to watch

Loan-broker

An example shipped with ServiceMix

Basic loan request scenario - a client requests a loan for a specific amount. A Bank services the request with an interest rate

Loan-broker continued...

Uses standard JMS on the client and an SE component on the server

Applies a transformation to assert rules related loan amount, credit score and term

Client

A non-JBI component

Issues a synchronous request to a JMS destination (Queue) and receives a response

Plain Java/JMS client, no configuration needed

Client CodeMessage out = requestor.getSession().createMapMessage();

out.setStringProperty("ssn", "012-24532-53254");out.setDoubleProperty("amount", Math.random() * 100000);out.setIntProperty("duration", (int) Math.random() * 48);

Message in = requestor.request(null, out);

Double rate = in.getDoubleProperty("rate");String bank = in.getStringProperty("bank");System.out.println("Response was: " + rate + " from " + bank);

Service Config - jbi.xml <service-assembly>

<identification> <name>loanbroker</name> <description>LoanBroker Service Assembly</description> </identification>

<service-unit> <identification> <name>loanbroker</name> <description>LoanBroker Service Unit</description> </identification> <target> <artifacts-zip>loanbroker-su.zip</artifacts-zip> <component-name>servicemix-lwcontainer</component-name> </target> </service-unit>

</service-assembly>

Component Config (xbean.xml)

<sm:activationSpec componentName="loanBroker" service="lb:loan-broker">

<sm:component> <bean class="loanbroker.LoanBroker" /> </sm:component> </sm:activationSpec>

xbean.xml continued...<sm:activationSpec componentName="bank1" service="lb:bank1">

<sm:component><bean class="loanbroker.Bank" /></sm:component></sm:activationSpec>

<sm:activationSpec componentName="bank2" service="lb:bank2"> <sm:component><bean class="loanbroker.Bank" /></sm:component></sm:activationSpec>

<sm:activationSpec componentName="bank3" service="lb:bank3"> <sm:component><bean class="loanbroker.Bank" /></sm:component></sm:activationSpec>

<sm:activationSpec componentName="bank4" service="lb:bank4"> <sm:component><bean class="loanbroker.Bank" /></sm:component></sm:activationSpec>

<sm:activationSpec componentName="bank5" service="lb:bank5"> <sm:component><bean class="loanbroker.Bank" /></sm:component></sm:activationSpec>

TransformationStandard Integration Pattern

Adapts from one message format to another

Uses a MessageExchange and a NormalizedMessage in

Provides adaptation/transformation to an output NormalizedMessage object

Lender Transformation

protected boolean transform(MessageExchange exchange, NormalizedMessage in, NormalizedMessage out) throws MessagingException

Transformation Definition

log.info("Receiving lender gateway request"); double amount = ((Double) in.getProperty(Constants.PROPERTY_AMOUNT)).doubleValue(); int score = ((Integer) in.getProperty(Constants.PROPERTY_SCORE)).intValue(); int hlength = ((Integer) in.getProperty(Constants.PROPERTY_HISTORYLENGTH)).intValue(); QName[] recipients; if (amount >= 75000.0 && score >= 600 && hlength >= 8) { recipients = new QName[] { new QName(Constants.LOANBROKER_NS, "bank1"), new QName(Constants.LOANBROKER_NS, "bank2") }; } else if (amount >= 10000.0 && amount < 75000.0 && score >= 400 && hlength >= 3) { recipients = new QName[] { new QName(Constants.LOANBROKER_NS, "bank3"), new QName(Constants.LOANBROKER_NS, "bank4") }; } else { recipients = new QName[] { new QName(Constants.LOANBROKER_NS, "bank5") }; } out.setProperty(Constants.PROPERTY_RECIPIENTS, recipients); return true;

Running the Demo

Integrations, when they work correctly, are highly uninteresting...

prepare to be let down :-)

Questions??

Thank you!