# Presentation: 630030

## A Comparison of Middleware Products

- Robert Antonucci
- robert.antonucci@commerceone.com

## Agenda

- What is Middleware
- History Lesson
- Different types of middleware
- What this means to you
- Real world example
- In depth discussion of most pertinent middleware

## What is Middleware

- Any reusable product that is used by the middle tier.
- The glue that turns your business logic into an application

## Middleware

- Connection

- Transactions

- Efficiency

- Pre-built Components

- Collaboration

- Communication

## History of Middleware

- Client-server (no middleware)
- First middle tiers
- Middle tiers for web applications
- Next Generation middle tiers

## Client-Server

- Thick Client

- Thick Client

- Thick
- Client

- SQL

- Whatever

## First Middle Tiers

- Thin Client

- Thin Client

- Thin Client

- Middle Tier

- Distributed Objects

- Messaging

- Database Connectivity

- Whatever

- Transactions

## Distributed Objects

- Code sees server object as if it existed on the client.

- Client

- Middle Tier

## Messaging

- Client makes requests in the form of a message
- Messages sit in queue until handled

- Client

- Middle Tier

## Messaging

- Also known as Queuing or Message Oriented Middleware (MOM)
- Best for when process may not always be available (remote client, non-24x7 server)

## Messaging Products

- Vendors
- IBM MQSeries
- Microsoft MSMQ
- Java JMS

- Features
- Guarantees of service
- Publish/subscribe
- Support transactions

## Database Connectivity

- Single API to database independent of brand
- OMG’s ODBC
- Java JDBC

## Transaction Processing

- Ensures that actions within a “transaction” either all happen or all do not

- void transfer	(Account toAccount,
- 		 Account fromAccount,
- 		 Money amount)
- {
- 	if (toAccount.available()<amount)
- 		  throw Exception();
- 	toAccount.withdraw(amount);
- 	fromAccount.deposit(amount);
- }

- fromAccount.withdraw(amount);
- toAccount.deposit(account);

## One Phase vs. Two Phase

- One Phase Commit simply makes changes and commits

- Transaction Monitor

- make changes

- commit

## Problem with One Phase Commit

- Multiple databases may result in an error after a commit.

- Transaction Monitor

- Database 1

- Database 2

- make changes

- commit

- Error has occurred, but first
- database has committed

## Two Phase Commit

- Phase One = preparation to commit
- Phase Two = commit

- Transaction Monitor

- Database 1

- Database 2

- make changes

- commit

- prepare

- If error occurs here,
- can abort both changes

## Using Two Phase Commits

- Necessary if using multipe database brands or distributed databases
- Requires high-end transaction monitor
- Requires every database support two phase commits (XA compliant)
- Direct negotiation between transaction monitor and database

## TP Vendors

- _BEA Tuxedo_
- _IBM CICS_
- Microsoft MTS _(only SQL Server)_
- OMG OTS
- Java JTS
- _supports 2 phase commit_

## Middle Tier for Web Applications

- Server(s)

- Web
- Server(s)

- Middle
- Tier

- Prepackaged
- Components

- Much Larger
- Demand

- Browsers

## Efficiency

- Get away from CGI (Java servlets and JSP, Microsoft ASP)
- Clustering – for performance and reliability
- Response time improvements
- Thread pooling
- Database connection pooling
- Resource pooling

## Application Servers

- Provide one solution that does everything
- Developers code fits in components running inside the application server
- Application server enforces component model
- Calling code never calls component directly, doesn’t even know where it is

## Application Server Design

- Web Server

- Application Server

- Component

- Make component distributed object
- Maintain transaction state
- Resource pooling
- Check security access

- call component

- call component

## Application Server Features

- Distribute objects
- Monitor transactions
- Impose security
- Load balancing
- High availability/fail over
- Resource management
- Object/Relational mapping

## EJB Server

- EJB is simply a standard that an application server must follow
- Includes a component model that all components (Enterprise Java Beans) must adhere
- Each application server can have extra features and different quality of services

## App Server Vendors

- EJB Vendors
- BEA WebLogic
- Sun Iplanet
- IBM Websphere
- Gemstone GemstoneJ
- Enhydra

- Non-EJB Vendors
- Microsoft MTS
- WebObjects

## Common Components

- State and session
- Shopping cart and ordering systems
- Catalog systems
- User accounts and preferences
- Workflow

## Next Generation Middle Tiers

- Web Server

- WAP Server

- Thin Client

## Web Middleware

- Final Middleware diagram

## Connecting to Distributed Objects

- Traditionally, distributed objects are found via Naming
- Very static – objects must be known at development time
- Discovery allows finding distributed objects by querying for desired behavior

## Collaboration

- Different systems cooperating will need to share some data while keeping the rest secure
- Idea of collaboration space on the internet for multiple parties to work.

## EAI

- Collaboration
- Space

- Contract

- Contractor

- Project Leader

- Program Manager

- Accounting

- bid

- approve

- accept

- process

## EAI Process

- Data is shared by several clients
- Data resides in collaboration space and each client acts on it
- Business rules and workflow enforce which clients can do what and when

## Using EAI

- Very complex with high setup costs
- Currently, mostly used in e-business
- Many EAI systems do more data conversion and integration with common office applications than internet collaboration
- BEA eLink leading vendor of full EAI engine

## Java Spaces

- Much simpler approach to collaboration

- Javaspace

- Producer

- Consumer

- X

- Post X

- X

- Look for X

- X

## Java Spaces

- Collaborates on data without knowing other collaborators
- Useful for distributed job processing
- Based on Java Jini technology
- Supports transactions

## Distributed Transactions

- Transaction monitors can manage multiple, disparate, distributed databases
- Requires direct monitor to database communication
- For security reasons, direct database communication not allowed
- Need a new type of transaction monitor

## Security

- So far, securing a system was burden on top tier.
- With new paradigm, middle tier must be secure.
- Requires changes to all areas of middleware

## Securing Middleware

- Authentication – distributed objects, messaging, discovery
- Encryption – distributed objects, messaging
- Role-based access – application servers, EAI
- New solutions to no access – distributed transactions, EAI, javaspaces

## What Does This Mean To You?

- Let’s say I had to build an observation planning and scheduling system.
- How would I use middleware to reduce the code I have to write?

## Real World Problem

- I have observing stations, each with their own scheduling system.  Different stations have different observation characteristics (eg. Visible light or radio observations)
- I have a planning system that coordinates scheduling of stations for simultaneous observation.

## Real World Design

- Planning
- Client

- Scheduling
- Client

- Planning
- Middle Tier

- Scheduling
- Middle Tier

- Schedule
- Database

- Plan
- Database

- ...

- ...

- ...

- Query for openings
- Schedule time

- Planning code

- Scheduling code

## Issues

- How will planner pick schedulers?
- How will planner communicate with schedulers?
- What if something fails?

## How will planner pick schedulers?Discovery

- Broker

- Service
- Requester

- Service
- Provider 1

- Service
- Provider 2

- Service
- Provider 3

- Need ObservationScheduler service
-     With frequency=visible

- Space Observation
- Freq=IR
- Pedigree=high

- Satellite Control
- Satellite=M12439

- Space Observation
- Freq=Visible
- Pedigree=low

- Service
- Provider 3

## Discovery Features

- Discovery of broker
- Security of system
- Power of search abilities

## Discovery Vendors

- Java Jini
- Device-to-device and internet-wide broker
- Immediate adoption, strong projected use
- Java’s run-anywhere very powerful
- HP E-Speak
- Internet-wide broker
- Very new
- Contains mediation, prebuilt components, and developers kit (all should work with Jini)

## More Vendors

- Microsoft BizTalk
- Internet-wide broker
- Brokers data and data format services rather than generic services
- HP JetSend
- Competitor to Jini in device-to-device market

## Planner Picks Scheduler

**Scheduler code**
**Register with Jini**
**Find Jini broker**
**Send distributed scheduling object with list of attributes**

**Planner code**
**Register with Jini**
**Find Jini broker**
**Ask for scheduler**
**Return distributed objects for all schedulers**
**Pick schedulers with desired frequency**

## How will planner communicate with schedulers? Distributed Objects

- Client

- Server

- ORB

- ORB

- Stub

- Distributed
- Object

- Skeleton

- method call

- method call encoded
-  as string of data

- TCP/IP

- data

- data

- data translated
- into method call

- method call

## Stub and Skeleton

- Stub and skeleton classes are generated automatically at compile time from interface
- Some tools use native language interface, some use language independent IDL
- Stub and skeleton carry method call, return value, and exceptions

## Distributed Object Features

- Guarantees of delivery
- Event notification (asynchronous communication)
- Pass by reference, pass by value
- Garbage collection
- Security features

## Distributed Object Vendors

- OMG CORBA
- Most sophisticated (complex) solution
- Cross platform, cross language
- IDL interfaces
- Full gamut of features
- Bridge to DCOM and to RMI
- Microsoft DCOM
- Mainly a Microsoft only tool
- Bridge to CORBA and port to Sun and Linux not used
- Uses COM interface
- Full gamut of features

## More Vendors

- Java RMI
- Simple solution, one-way method calls only
- Works only with Java (and CORBA bridge)
- Built in authentication and encryption
- Uses Java interfaces
- SOAP
- Very simple, XML data over HTTP
- Advertised as good with firewalls
- Uses XML definition of interfaces
- Very new, but strong acceptance

## Planner Communicates with Scheduler

**Planner code**
**Query schedule for open slot**
**Serialize method call**
**Send call to server**
**Receive reply**
**Translate as return type or exception**
**Catch and handle exception**

**Scheduler code**
**Run ORB**
**Listen for incoming methods**
**Receive data**
**Translate data and call method**
**Search for open slot**
**Throw exception if failure**
**Translate return value or exception into data**
**Send data **

## Solution So Far

**Planner code**
**Register with Jini**
**Ask for scheduler**
**Pick schedulers with desired frequency**
**Query schedulers for open slot**
**Reserve common slot in schedules**
**Catch and handle exception**

**Scheduler code**
**Run ORB**
**Register with Jini**
**Search for open slot**
**Throw exception if failure**
**Reserve requested slot**
**Throw exception if failure**

## What if something fails?Distributed Transactions

- Planner

- reserve slot

- commit

- prepare

- If error occurs here,
- can abort both changes

- Radio Scheduler

- Visible Scheduler

## “Two Phase Commit” Scheduler

- The prepare/commit is raised from database to business logic
- Business logic may or may not have access to database primitives

## Handling When Something Goes Wrong

**Planner code**
**Start transaction**
**Request slot on desired schedulers**
**End transaction**
**Send prepare request to all schedulers**
**If any errors detected send abort**
**If any dropped connections continue to send prepare until timeout**
**Send commit**
**Continue to send commit until acknoledgement**

**Scheduler Code**
**Remember slot has been requested**
**Prepare for commit by grabbing all necessary locks**
**Commit or release locks**

## Full Solution

**Planner code**
**Register with Jini**
**Ask for scheduler**
**Pick schedulers with desired frequency**
**Query schedulers for open slot**
**Start Transaction**
**Reserve common slot in schedules**
**End Transaction**
**Catch and handle exception**

**Scheduler code**
**Run ORB**
**Register with Jini**
**Search for open slot**
**Remember requested slot is reserved**
**Gather locks for slot**
**Commit**

## Middleware

- Connection

- Transactions

- Efficiency

- Pre-built Components

- Collaboration

- Communication

- Distributed Objects
- Messaging
- Database Connectivity

- Naming
- Discovery

- TP Monitors
- Distributed TP Monitors

- Application
- Servers

## Summary

- Middleware is the infrastructure around your business logic
- You code the process with no complications, middleware handles the complications
- Using middleware can significantly save development time

## A Comparison of Middleware Products

- Robert Antonucci
- robert.antonucci@commerceone.com