An Overview of JBI
description
Transcript of An Overview of JBI
![Page 1: An Overview of JBI](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/1.jpg)
An Overview of JBI
May 2007
![Page 2: An Overview of JBI](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/2.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/3.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/4.jpg)
A motivating example...
Consider the traditional client/server application...
![Page 5: An Overview of JBI](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/5.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/6.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/7.jpg)
Definitions...
![Page 8: An Overview of JBI](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/8.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/9.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/10.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/11.jpg)
Web Service
Based on open standards
Discoverable, distributed Service
XML based interaction
Platform agnostic
Vendor neutral
![Page 12: An Overview of JBI](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/12.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/13.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/14.jpg)
Document Structure
<definitions>
<types></types>
<message></message>
<portType></portType>
<binding></binding>
</definitions>
![Page 15: An Overview of JBI](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/15.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/16.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/17.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/18.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/19.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/20.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/21.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/22.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/23.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/24.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/25.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/26.jpg)
So what were integrations prior
to JBI?
![Page 27: An Overview of JBI](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/27.jpg)
Integrations, silly!
![Page 28: An Overview of JBI](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/28.jpg)
Integration Patterns
![Page 29: An Overview of JBI](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/29.jpg)
Integration Components
Application(s)
Channel
Message
Endpoints
Message Router
![Page 30: An Overview of JBI](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/30.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/31.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/32.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/33.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/34.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/35.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/36.jpg)
Ok John, get to the point!
![Page 37: An Overview of JBI](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/37.jpg)
Java Business Integrations
![Page 38: An Overview of JBI](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/38.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/39.jpg)
JBI - What? part deux
Divided into Service Engine Components and Binding Components
Components communicate through mediated Message Exchanges
![Page 40: An Overview of JBI](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/40.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/41.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/42.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/43.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/44.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/45.jpg)
JBI Architecture
WSDL-based Messaging Model
Declarative (XML) service model
Supports plug-in components
Management configuration through JMX
![Page 46: An Overview of JBI](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/46.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/47.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/48.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/49.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/50.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/51.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/52.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/53.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/54.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/55.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/56.jpg)
Runtime Environment
![Page 57: An Overview of JBI](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/57.jpg)
Sample Invocation
Image obtained from: http://incubator.apache.org/servicemix/5-jbi.html
![Page 58: An Overview of JBI](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/58.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/59.jpg)
Component Lifecycle
![Page 60: An Overview of JBI](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/60.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/61.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/62.jpg)
Packaging Types cont...
Service Assemblies - collection of Service Units
Unit of Deployment is the Service Assembly in JBI
![Page 63: An Overview of JBI](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/63.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/64.jpg)
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 65: An Overview of JBI](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/65.jpg)
Sample xbean.xml
<beans xmlns:http="http://servicemix.apache.org/http/1.0" xmlns:replaceMe="http://servicemix.apache.org/replaceMe">
<http:endpoint service="replaceMe:withYourService" endpoint="soap" role="consumer" locationURI="http://localhost:8192/example/" defaultMep="http://www.w3.org/2004/08/wsdl/in-out" soap="true" />
</beans>
![Page 66: An Overview of JBI](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/66.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/67.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/68.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/69.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/70.jpg)
Things not covered...
Distributed Component Transactions
Event-based architectures
UDDI, Service Registry and Discovery
Security (WS-basic profile)
![Page 71: An Overview of JBI](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/71.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/72.jpg)
Demo
Basic (legacy) Integration Scenario using JMS and Apache ServiceMix
Successful integrations are uninteresting to watch
![Page 73: An Overview of JBI](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/73.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/74.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/75.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/76.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/77.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/78.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/79.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/80.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/81.jpg)
Lender Transformation
protected boolean transform(MessageExchange exchange, NormalizedMessage in, NormalizedMessage out) throws MessagingException
![Page 82: An Overview of JBI](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/82.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/83.jpg)
Running the Demo
Integrations, when they work correctly, are highly uninteresting...
prepare to be let down :-)
![Page 84: An Overview of JBI](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/84.jpg)
Questions??
![Page 85: An Overview of JBI](https://reader036.fdocuments.net/reader036/viewer/2022062408/56813bec550346895da51bed/html5/thumbnails/85.jpg)
Thank you!