An Overview of JBI

85
of JBI May 2007

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 of An Overview of JBI

Page 1: An Overview  of JBI

An Overview of JBI

May 2007

Page 2: An Overview  of JBI

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

Page 3: An Overview  of JBI

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.

Page 4: An Overview  of JBI

A motivating example...

Consider the traditional client/server application...

Page 5: An Overview  of JBI

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

Page 6: An Overview  of JBI

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

Page 7: An Overview  of JBI

Definitions...

Page 8: An Overview  of JBI

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.

Page 9: An Overview  of JBI

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

Page 10: An Overview  of JBI

ESB continued...

Distributed Data transformation

Remote configuration and management

Uses XML as the lingua franca of communication

Real-time Business data

Page 11: An Overview  of JBI

Web Service

Based on open standards

Discoverable, distributed Service

XML based interaction

Platform agnostic

Vendor neutral

Page 12: An Overview  of JBI

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

Service provider

Service requestor

Intermediary

Initial sender

Ultimate receiver

Page 13: An Overview  of JBI

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

Page 14: An Overview  of JBI

Document Structure

<definitions>

<types></types>

<message></message>

<portType></portType>

<binding></binding>

</definitions>

Page 15: An Overview  of JBI

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>

Page 16: An Overview  of JBI

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

Page 17: An Overview  of JBI

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

Page 18: An Overview  of JBI

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>

Page 19: An Overview  of JBI

Messaging

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

Page 20: An Overview  of JBI

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)

Page 21: An Overview  of JBI

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)

Page 22: An Overview  of JBI

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

Page 23: An Overview  of JBI

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

Page 24: An Overview  of JBI

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

Page 25: An Overview  of JBI

Basic Integration

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

Page 26: An Overview  of JBI

So what were integrations prior

to JBI?

Page 27: An Overview  of JBI

Integrations, silly!

Page 28: An Overview  of JBI

Integration Patterns

Page 29: An Overview  of JBI

Integration Components

Application(s)

Channel

Message

Endpoints

Message Router

Page 30: An Overview  of JBI

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

Page 31: An Overview  of JBI

Channel

Logical address, not physical

Agreed upon by both consumer and producer

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

JMS: Topic or Queue

Page 32: An Overview  of JBI

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

Page 33: An Overview  of JBI

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

Page 34: An Overview  of JBI

Message Router

Logcially routes messages based on payload, content or other metadata

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

Page 35: An Overview  of JBI

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.

Page 36: An Overview  of JBI

Ok John, get to the point!

Page 37: An Overview  of JBI

Java Business Integrations

Page 38: An Overview  of JBI

JBI - The What?

JSR 208, Standard Specification

Infrastructure and Component framework for integrations

JBI Components plug into the JBI Framework

Page 39: An Overview  of JBI

JBI - What? part deux

Divided into Service Engine Components and Binding Components

Components communicate through mediated Message Exchanges

Page 40: An Overview  of JBI

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

Page 41: An Overview  of JBI

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

Page 42: An Overview  of JBI

JBI ManagementManagement Structure based on JMX

Standardizes:

Installation

Managing component lifecycle

Deploying services to components

Components can act as a container for other components

Page 43: An Overview  of JBI

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

Page 44: An Overview  of JBI

Roles continued...

System Administrator – installs, configures and monitors the JBI environment

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

Page 45: An Overview  of JBI

JBI Architecture

WSDL-based Messaging Model

Declarative (XML) service model

Supports plug-in components

Management configuration through JMX

Page 46: An Overview  of JBI

WSDL Messaging Model

Produces or Consumes services using WSDL 1.1 or WSDL 2.0 specifications

Abstract Model

Concrete Model

Page 47: An Overview  of JBI

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

Page 48: An Overview  of JBI

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

Page 49: An Overview  of JBI

Normalized Message Router

(NMR)Receives Message Exchanges from JBI components

Routes to appropriate handling component

Decouples Producers from Consumers enabling different processing

Page 50: An Overview  of JBI

Normalized Message

Defined earlier

JBI’s “version” of a plain Message

Consists of 3 parts:

Message metadata for routing

Payload

Arbitrary attachments

Page 51: An Overview  of JBI

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

Page 52: An Overview  of JBI

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

Page 53: An Overview  of JBI

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

Page 54: An Overview  of JBI

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) { ...}

Page 55: An Overview  of JBI

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

Page 56: An Overview  of JBI

Runtime Environment

Page 57: An Overview  of JBI

Sample Invocation

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

Page 58: An Overview  of JBI

JBI Components

Service Providers - fulfills the particular service request

Service Consumers - invokes a given service either directly or indirectly

Page 59: An Overview  of JBI

Component Lifecycle

Page 60: An Overview  of JBI

Packaging JBI Components

Defines standard packaging for new components

Components use a descriptor, jbi.xml

Packaged as .zip or .jar files

Page 61: An Overview  of JBI

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.

Page 62: An Overview  of JBI

Packaging Types cont...

Service Assemblies - collection of Service Units

Unit of Deployment is the Service Assembly in JBI

Page 63: An Overview  of 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

Page 64: An Overview  of JBI

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>

Page 66: An Overview  of JBI

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.

Page 67: An Overview  of JBI

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

Page 68: An Overview  of JBI

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

Page 69: An Overview  of JBI

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

Page 70: An Overview  of JBI

Things not covered...

Distributed Component Transactions

Event-based architectures

UDDI, Service Registry and Discovery

Security (WS-basic profile)

Page 71: An Overview  of JBI

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

Page 72: An Overview  of JBI

Demo

Basic (legacy) Integration Scenario using JMS and Apache ServiceMix

Successful integrations are uninteresting to watch

Page 73: An Overview  of JBI

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

Page 74: An Overview  of JBI

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

Page 75: An Overview  of JBI

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

Page 76: An Overview  of JBI

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);

Page 77: An Overview  of JBI

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>

Page 78: An Overview  of JBI

Component Config (xbean.xml)

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

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

Page 79: An Overview  of JBI

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>

Page 80: An Overview  of JBI

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

Page 81: An Overview  of JBI

Lender Transformation

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

Page 82: An Overview  of JBI

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;

Page 83: An Overview  of JBI

Running the Demo

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

prepare to be let down :-)

Page 84: An Overview  of JBI

Questions??

Page 85: An Overview  of JBI

Thank you!